I have an object which contains a list of another object as follow:
class cl
{
List<a> a ;
public List<a> listofA
{
get; set;
}
}
class a
{
//other properties
string comment ;
public string comment
{
get; set;
}
}
Now how do i make a linq query to see if comment is of some string here is my query:
var query = (from c in scope.Extent<cl>()
where c.Date >= dateFrom && c.Date < dateTo
&& c.Actions.Where(a => (a.comment== "") )
orderby c.Date.Value.Date
group c by c.Date.Value.Date into grpDate
select new { grpDate.Key, items = grpDate });
but i get error saying :
Error 15 Operator '&&' cannot be applied to operands of type 'bool' and 'System.Collections.Generic.IEnumerable<>
Error 13 Cannot convert lambda expression to type 'string' because it is not a delegate type
The problem is you’re using
c.Actions.Where. This returns anIEnumerable<T>, not abool, but you’re doing a check for your where clause which expects a boolean value.You can most likely solve this by using
Anyinstead ofWhere: