Alan Alan - 1 year ago 60
ASP.NET (C#) Question

How can I convert a count returned from LINQ into a List?

In my code I am using this to do a count of rows in a table:

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

I have on my front end a report viewer that expects to see data in the form of a List with Col1, Col2 etc and then the values assigned to each.

Ia there a way that I can make this .CountAsync() return it's value in the form of a list with one row with the value assigned to a field 'col1'?

Something like this:

.Select new { ?? };

Answer Source

How about:

var phrasesCount = await db.Phrases.CountAsync();
return new List<object>
        Col1 = phrasesCount
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download