LINQ C# - Unable to cast object of type 'System.Double' to type 'System.String'.

  • Thread starter Thread starter Gani tpt
  • Start date Start date
G

Gani tpt

Guest
i am just checking parameter string "2(MN)" to my data table.

I am getting error "Additional information: Unable to cast object of type 'System.Double' to type 'System.String'."

List<string> EmpTypeFilter = { "2(MN)" };
Qry = (from r in dt2.AsEnumerable()
where ContainsStringExtensions.ContainsAny(r.Field<string>("EMPTYPE"), EmpTypeFilter)
&& !string.IsNullOrEmpty(r.Field<string>("EMPTYPE").ToString()) // Error
select new
{

}).Count();

public static class ContainsStringExtensions
{
public static bool ContainsAny(this string haystack, IEnumerable<string> filterList)
{
return haystack != null && filterList.Any(haystack.Contains);
}
}
what is the error...?

Continue reading...
 
Back
Top