i have a query in linq like this.
var res = from UM in linq.AG_User_Masters
where UM.Login_id == txt_loginname.Text
select UM;
now i have to check that res contain any result or not..
but i do not getting this abjectly...
so pls help...
Thanks....

Jaganathan BantheswaranPosted Dec 12, 2013, 2:03 AM
The res never be null. The linq query will return the IEnumerable
So you have to check like
if(res.Count > 0)
{
// do something
}
Vivek KumarPosted Sep 29, 2015, 6:56 AM
Jaganathan BantheswaranPosted Dec 12, 2013, 4:36 AM
As Jignesh Trivedi's reply, Assign it to the property. It should work.
Let us know if you have doubts.
Jignesh TrivediPosted Dec 12, 2013, 2:36 AM
hi,
here i have some suggetion...
use
if (res!=null && res.Count() > 0 )
{
return 1;
}
else
{
return 0;
}
also try...
var grid_data = from AG_User_Master in linq.AG_User_Masters
where AG_User_Master.user_name.Contains(@txt_search.Text)
select new
{
Name = AG_User_Master.user_name,
Login = AG_User_Master.Login_id,
Role = AG_User_Master.Role,
password = AG_User_Master.password,
mydate = AG_User_Master.c_Date,
};
dataGridView1.DataSource = grid_data;
hope this will help you.
Mukesh Kumar TiwariPosted Dec 12, 2013, 2:27 AM
sir this is working..and
thanks for lead me......
and one more problem is there
Error mes is like this: unable to cat object of type System.DateTIme to type system.string