Here is my code:
var value = query.Select(
a => new CHART_MODEL
{
TEXT = "xyz",
COUNT1 = (a.TOPLAM_FIYAT != null).ToString().Count(),
COUNT2 = (a.TOPLAM_FIYAT == null) ? ToString().Count() : 0
}
).ToList();
Here is the error:
System.NotSupportedException: 'LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.'
and CHART_MODEL
public class CHART_MODEL
{
public int COUNT1 { get; set; }
public int COUNT2 { get; set; }
public string TEXT { get; set; }
}
My question is: I have to calculate null and non null values with Count(). but it doesn't allow me to write. I don't know how to rearrange linq query code in correct way with Count().