ADO.NET :: Unable To Fetch Just One Integer Value Using This LINQ-query
Aug 16, 2010
I'm unable to fetch just one integer value using this LINQ-query. LINQ seems to return everything as IEnumerable but I don't want that. First query should return just one string value which is then used in another query. That one should return integer which is also return value for method:
public static long GetTableIdByTableName(string name)
{
var result = (from aTable in objScope.Extent<Table>()
where aTable.Name == name
select { aTable.Id });
return ???????????
}
View 1 Replies
Similar Messages:
May 28, 2010
I'm looking to translate an SQL query into linq
INNER JOIN Usrs ON
SAQ.UserId =
Usrs.UserId AND Scan.UserId =
Users.UserId
I'm not sure how to include the "AND" in the LINQ statement.
View 3 Replies
Mar 18, 2011
I have a query which need to search on account table where search criteria looks at either partial name(string column) or partial accountid (integer column).
Linq doesn't allow tostring on integer column to find partial search. The example would be search account number which begins with 124. There might be account numbers like: 1247, 1249 etc which need to be returned. On the name side, searching for string that begins with joh would return john, johk, johp etc.
FYI: The query should return Account table records not annonymous types.
[Code]....
View 17 Replies
Feb 16, 2010
I have a method is code behind like this:
Code:
[code]....
but it doesn't print out anything. IsLocked in the db is integer type. It should print out "1" .. If I just do Eval("IsLocked") then it prints out 1..
View 27 Replies
Feb 8, 2011
i dont understand where is the problem with my code. i need to pass the request_id to another page but it is always passing the integer values as 0. whenever it comes to pass integer values it is passing it as 0 even if i perform conversion of string to int.
[Code]....
View 6 Replies
Jul 8, 2010
I had a stored procedure as below. I'm trying to return an integer of differences btw 2 integers. In SQL Server 2008, the stored procedure works just fine, it shows me the value I wanted in @intdiff.
But when I try to retrieve it with my webservice, it only return value 0. My webservice coding as below. Could any1 come accross this before?
Stored Procedure
[Code]....
Web Service
[Code]....
View 2 Replies
Oct 26, 2010
i'm trying to fetch data from xml in the sql query.
DECLARE @xmlDelete xml
SET
@xmlDelete =
'<DocumentElement>
<row FSFF_FeesItemID="185" FSI_ID="104" />
<row FSFF_FeesItemID="187" FSI_ID="104" />
<row FSFF_FeesItemID="187" FSI_ID="105" />
</DocumentElement>'
;
WITH
r_set AS
(
SELECT
T1
.c1.value('(./FSFF_FeesItemID/text())[1]',
'int')
AS [id1]
,
T1
.c1.value('(./FSI_ID/text())[1]',
'int')
AS.......................................
View 2 Replies
Jan 22, 2011
I m working on LINQ, using LINQ i m getting data in one to many environment, means
(1)table1 (master table)
(2)table1.table2 (here table2 is child table)
I m able to get data of table1 and table2 based on condition. and i storing in var variable.
but my problem is that i want to get data using SQL query and i want to assign fecthed data to class CLStable1(calss for table1) and class CLStable2(calss for table2).
View 2 Replies
Jan 4, 2010
I am using following oracle query and using executescalar() to fetch data
sql = "select username from usermst where userid=2"
string getusername = command.executescalar();
But It is showing me error "System.NullReferenceException: Object reference not set to an instance of an object"
This error comes when there is no row exist in database for userid=2
View 4 Replies
Mar 27, 2011
I have two tables and following are the structure of both the tables
Tbale 1
Field1 Field2 Field3
d1 01 26/03/2011
d2 02 26/03/2011
d3 03 27/03/2011
Table2
Field1 Field2 Field3
01 6.15 14.25
02 7.30 16.25
03 6.00 18.25
My expected output when i search records by table1.field3 (say 26/03/2011)
Tbale 1
Table1.Field1 Table2.Field2 Table3.Field3 Table2.field2 Table2.Field3
d1 01 26/03/2011 6.15 14.25
d2 02 26/03/2011 7.30 16.25
d3 03 27/03/2011
Inorder to get the above result, what query should i write?
View 4 Replies
Sep 13, 2010
I have a textbox with numeric updown extender.I want the text of the textbox.I have written code in code file is
String a=txtHour.Text
// Source FIle COde
<asp:TextBox ID="txtHour" runat="server" ReadOnly="True" Width="45"
Style="text-align:center" Height="20px">
</asp:TextBox>
<cc1:NumericUpDownExtender ID="NumericUpDownExtenderHr" runat="server"
Enabled="True"
Minimum="00" Maximum="23"
TargetControlID="txtHour" Width="40">
</cc1:NumericUpDownExtender>
View 3 Replies
Feb 11, 2011
I want to use "if statement" in Linq query. How can I do this situation?
For example:
if txtAge.Text=="", I will not use that in Linq Query.
else txtAge.Text!="", I will use that in Linq Query.
View 8 Replies
Sep 14, 2010
I've build a linq query.But i want a random selection so its not always ID : 1,2,3,4,5,6 How can i randomize this var? I like to bind it to a repeater.//TagCloud:
Random rand = new Random();
var tc1 = from i in JumpTide.cms.menu.GetMenuItems(32)
select new
[code]...
View 1 Replies
Mar 10, 2010
select Groupid,GroupName,onorusername from palgroup where groupid in (select distinct Groupid
View 5 Replies
Mar 19, 2011
I am facing a big problem with simple linq query.. I am using EF 4.0..
I am trying to take all the records from a table using a linq query:
var result = context.tablename.select(x=>x);
This results in less rows than the normal sql query which is select * from tablename;
This table has more than 5 tables as child objects (foreign key relations: one to one and one to many etc)..
This result variable after executing that linq statement returns records with all child object values without doing a include statement.. I don't know is it a default behavior of EF 4.0 . I tried this statement in linqpad also..but there is no use... But interesting thing is if I do a join on the same table with another one table is working same is sql inner join and count is same..but I don't know why is it acting differently with that table only.. Is it doing inner joins with all child tables before returning the all records of that parent table?
View 2 Replies
Oct 17, 2010
I am writing a linq query to select a blogpost,
[code]....
The blogpost i am testing got 3 tags attached to it. The table structure is:
(table)BlogPost -> (table)BlogPostTags <- (table)Tags
So the BlogPostTags table only contains 2 fields, BlogPostID and TagID.
When i run the query above i get 3 results back. Same blogpost 3 times but with 1 tag in each. It should return 1 post with 3 tags. The problem lies in the Tags query above.
View 1 Replies
Aug 11, 2010
I have a repeater which is binded using a Collection of Entity Data Framework.
Once the repeater is binded using the datasource, the user can control the no of rows present in the repeater using a Dropdown list on the page. For ex: if datasource has 2 rows, user want to add 3 more rows, user selects 5 from dropdown, which adds 3 additional rows to the Repeater. I am able to do this.
The repeater has textbox controls in each row. Now once the user enter the values in this textbox of the newly generated rows, the user can save the values entered with the no of rows specified.
I have a button which is outside the repeater and on click of this i need to validate all the textbox values and save them into dB accordingly.
Here is my code
Repeater.aspx
[Code]....
[Code]....
Repeater.aspx.cs
[Code]....
Right now the problem is im not able to fetch the values of the textboxes present in the newly generated rows.
[URL]
View 1 Replies
Jan 22, 2011
I have a web app for our golf club. When I compute handicap index for each golfer, I have to select the most recent scores and then a subset of those scores depending on how many rounds of golf the golfer has played. All the scores are entered into a single SQL Express table called "Rounds". Verbally, this is what I'm trying to do:
1) select the twenty most recent golf scores (sort on date descending, "take(20)") [if less than 20 records, then select all available];
2) for this set of records, select the 10 lowest scores (or smaller number if golfer has less than 20 rounds);
3) compute the average round differential for the subset of records, etc. to calculate handicap index (this step is working ok...)
My current VB code has this LINQ query (which is flawed -- it selects the lowest handicap differential scores of ALL records for the filtered user):
[Code]....
How do I modify this query to accomplish items 1) & 2) above? It seems this should be simple, but my experience with queries is still limited.
View 2 Replies
Feb 18, 2010
To write a join query with or condition. It means a query has two inner join, here it is possible to fetch the records, if one inner join is true and other is false. I got a record when only two join conditions are true.
View 1 Replies
Jul 18, 2010
Using Visual Studio I've created a DBML file, and added a table to it from a local database. This created a data context called UserDataContext. In my ASPX page I can create an instance of the data context using:
UserDataContext db1 = new UserDataContext();
However when I try to query against the table I get to:
var query = from o in db1.
and from there I can't see the table.... the dbml shows the table has public access.
View 6 Replies
Aug 2, 2010
I have a list which contains few email ids
List<string> EmailId= { ....}
Now I have a db table Users. I need to select all users whose email exist in the above list. In sql we could write "where emailid in ('email1', email2' ,...)"
how to do this in linq to sqlquerable<Users> existingUsers = Users.getTable().where (u=>u.emailaddress in EmailId). I want to do some thing similar
View 2 Replies
Sep 12, 2010
I need to figure out how to express this in linq to sql:I have one or more records that contain what is essentially a wildcard sql parameter, like '100_-___-2', which should match 100[any 1 char]-[any 1 char][any 1 char][any 1 char]-2, for example. Each login will have one or more of these 'datamasks' associated with it.I need to write a query in linq to sql that does something like:
select * from something
where fieldA = 'someValue' or fieldB = 'someValue'
so far, simple, but I also need to restrict the returned records to only those that match the user's 'datamasks'. I'm not sure exactly how to translate this to linq to sql... here is what a working query *without* the datamasks part looks like:
[Code]....
I need to tack on the datamasks part... can I do it right there in the same statement? or do I need to do a foreach loop on the datamasks records and append a new && condition for each one? hmmm... just thought of that as I was writing this.. I'll try that out. But I'm posting this anyway for more input... I guess that would look something like:
foreach (string mask in datamasks)
{
query = query.Where(item =>
System.Data.Linq.SqlClient.SqlMethods.Like(item.AccountNum, mask));
}
would that work? would each additional 'where' condition be 'appended' to the existing query definition?
View 3 Replies
Mar 11, 2010
Users
Roles
UserRoles
MenuItems
RoleMenuItems
A User can have multiple Roles and a MenuItem can be accessed by multiple Roles. Now I want to write a method as follows:
public IList<MenuItems> GetMenuItems(UserRoles userRoles)
{
var menus = // LINQ query to get the MenuItems by UserRoles
return menus.ToList();
View 1 Replies
Aug 31, 2010
I declared a 3 X 3 Matrix
int[,] matrix=new int[3,3]
{
{1,2,3},
{4,5,6},
{11,34,56}
};
when i try to enumerate it like var diagonal = matrix.AsQueryable().Select(); I am unbale to convert it as enumerable collection.How to do that?
View 2 Replies
Aug 31, 2010
I need to use Union for below Linq queries. I could use Union it if it was simple "select new whith{" but Now that I Specified Class, I encounter Error using union
[Code]....
View 3 Replies