I work with Entity Framework. There is a class
class Entity { public string Name { get; set; } public bool IsMain { get; set; } } I get data from the database using GroupBy:
var grouppedEntitiesByName = context.GetEntities<Entity>().GroupBy(en => en.Name); The database has the following data:
IsMain = true, Name = "entity" IsMain = false, Name = "entity" IsMain = true, Name = "Entity" After I do this:
foreach (var entity in grouppedEntitiesByName) { var mainEntity = entity.Single(a => a.IsMain); } Here I get the error Sequence contains more than one matching element. The fact is that GroupBy gives three elements, it seems he does not distinguish between small and large letter. After I used ToList:
var grouppedEntitiesByName = context.GetEntities<Entity>().ToList().GroupBy(en => en.Name); Everything is working. But why it does not work with IQueryable. Is there any solution to this problem?
Contains,GroupByand others - Andrey NOP