Alan Alan - 6 months ago 29
C# Question

Is there a way that I can get a count of rows with a LINQ statement?

I have been using this LINQ statement:

var phrases = await db.Phrases

But what I need is to get a count of the number of rows in Phrases.

I have never used LINQ to do this before. Is there a way that I can do this?


The sync version:

var phrasesCount = db.Phrases.Count();

The async version (assuming this is EF):

var phrasesCount = await db.Phrases.CountAsync();