0

I have a problem with Group by in lambda expression, Lets say I have the following SQL query:

SELECT [name] FROM [db].[dbo].[table] GROUP BY [key]

I want to get the same result using lambda expression, I tried this :

IQueryable<table> query = context.table.GroupBy(s => s.key);

But I get "missing cast" error.

What I miss here?

Abdulsalam Elsharif
  • 4,773
  • 7
  • 32
  • 66

1 Answers1

0

Please try this.

IQueryable<table> query = context.table..AsQueryable().GroupBy(s => s.key)..SelectMany(x => x);
Hemang A
  • 1,012
  • 1
  • 5
  • 16