Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
mY LINQ QUERY IS

C#
var b = from i in Inspinias
       where i.Email.Contains("jayesh@gmail.com")
       select i.Name;


BUT RETURNS NOTHING
Posted
Updated 8-Mar-15 20:22pm
v3
Comments
Are your sure this mail id is present inside the list? Also don't post email in a forum, you will get many spams.
John C Rayan 7-Mar-15 9:59am    
Not clear!
Dave Kreskowiak 7-Mar-15 11:18am    
What is "Inspinias"? What is the code that defines it?

One possible problem is that the database does not have a record that matches your where clause EXACTLY.

1 solution

You can retrieve all the results by using select i or you can select fields as follows:
C#
var b = from i in Inspinias
        where i.Email.Contains("jayesh@gmail.com")
        select new
        {
          i_name = i.Name
        };

//retrieve it as..
foreach (var rec in b)
{
   //rec.i_name;
}
 
Share this answer
 
v2
Comments
Maciej Los 29-Mar-15 6:52am    
Voted 4, because of select new{} is unnecessary, but you're right that OP needs to loop through the collection of "records" returned via linq query.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900