Convert this SQL Count statement to LINQ statement

150 Views Asked by At

How would this SQL statement be with LINQ if I use Count?

select count(*) from GoalCard
where GoalCard.Completed_Date is not null

Thanks in advance!

Update:

I would remove the " too localized " votes, beacuse there are peoples that use google to find how count can be used in a LINQ statement.

2

There are 2 best solutions below

0
On BEST ANSWER

Use this:

context.GoalCards.Count(gc => gc.Completed_Data != null);
0
On

Count:

context.GoalCards.Count(x => x.Completed_Date.HasVale)