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 BantheswaranRank #170 · 14.1K reputationPosted Dec 11, 2013, 9:03 PM EST
The res never be null. The linq query will return the IEnumerable
So you have to check like
if(res.Count > 0)
{
// do something
}
Mukesh Kumar TiwariRank #1,774 · 844 reputationPosted Dec 11, 2013, 9:27 PM EST
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
Jignesh TrivediRank #16 · 50.3K reputationPosted Dec 11, 2013, 9:36 PM EST
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.
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Dec 11, 2013, 11:36 PM EST
As Jignesh Trivedi's reply, Assign it to the property. It should work.
Let us know if you have doubts.
Vivek Kumar3 reputationPosted Sep 29, 2015, 2:56 AM EDT