G
Gani tpt
Guest
I am not getting proper count even if i pass the correct values.
below is my code.
DataTable dt = new DataTable();
dt.Columns.Add("EmpId", typeof(string));
dt.Columns.Add("FirstName", typeof(string));
dt.Columns.Add("LastName", typeof(string));
dt.Columns.Add("Country", typeof(string));
dt.Rows.Add("1", "John", "Hammond", "USA");
dt.Rows.Add("2(US)", "Mudassar", "", "Canada");
dt.Rows.Add("3", "Suzanne", "Mathews", "");
dt.Rows.Add("4", "Robert", "", "Russia");
string empid = "2";
//string valcontains = "BS";
List<string> valcontains = new List<string>() { "BS" };
//string FinalValue, strSpring = null;
var Qry = (dynamic)null;
Qry = 0;
Qry = (from r in dt.AsEnumerable()
where
r.Field<string>("EmpId") == empid
&& Condtions.ContainsAny(r.Field<string>("EmpId"), valcontains)
select new
{
}).Count();
if (Qry > 0)
{
//FinalValue = strSpring;
}
I am passing the empid = "2".
result should say, if empid contains "BS" in the datatable
then boolean FLAG1 = true,
else FLAG1 = false
How do we write in single line of LINQ code..?
Continue reading...
below is my code.
DataTable dt = new DataTable();
dt.Columns.Add("EmpId", typeof(string));
dt.Columns.Add("FirstName", typeof(string));
dt.Columns.Add("LastName", typeof(string));
dt.Columns.Add("Country", typeof(string));
dt.Rows.Add("1", "John", "Hammond", "USA");
dt.Rows.Add("2(US)", "Mudassar", "", "Canada");
dt.Rows.Add("3", "Suzanne", "Mathews", "");
dt.Rows.Add("4", "Robert", "", "Russia");
string empid = "2";
//string valcontains = "BS";
List<string> valcontains = new List<string>() { "BS" };
//string FinalValue, strSpring = null;
var Qry = (dynamic)null;
Qry = 0;
Qry = (from r in dt.AsEnumerable()
where
r.Field<string>("EmpId") == empid
&& Condtions.ContainsAny(r.Field<string>("EmpId"), valcontains)
select new
{
}).Count();
if (Qry > 0)
{
//FinalValue = strSpring;
}
I am passing the empid = "2".
result should say, if empid contains "BS" in the datatable
then boolean FLAG1 = true,
else FLAG1 = false
How do we write in single line of LINQ code..?
Continue reading...