generated-sql

Get max & min from Entity Framework, in one query and with best query possible

吃可爱长大的小学妹 提交于 2019-12-01 16:35:17
I'm aware of this question, but what I would like to do is obtain something close to this generated SQL: select MAX(Column), MIN(Column) from Table WHERE Id = 1 When I try this: var query = from d in db.Table where d.Id == 1 select new { min = db.Table.Max(s => s.Column), max = db.Table.Min(s => s.Column) }; The generated sql looks like this: SELECT [Extent1].[Id] AS [Id], [GroupBy1].[A1] AS [C1], [GroupBy2].[A1] AS [C2] FROM [dbo].[Table] AS [Extent1] CROSS JOIN (SELECT MAX([Extent2].[Column]) AS [A1] FROM [dbo].[Table] AS [Extent2] ) AS [GroupBy1] CROSS JOIN (SELECT MIN([Extent3].[Column])

Get max & min from Entity Framework, in one query and with best query possible

99封情书 提交于 2019-12-01 15:21:18
问题 I'm aware of this question, but what I would like to do is obtain something close to this generated SQL: select MAX(Column), MIN(Column) from Table WHERE Id = 1 When I try this: var query = from d in db.Table where d.Id == 1 select new { min = db.Table.Max(s => s.Column), max = db.Table.Min(s => s.Column) }; The generated sql looks like this: SELECT [Extent1].[Id] AS [Id], [GroupBy1].[A1] AS [C1], [GroupBy2].[A1] AS [C2] FROM [dbo].[Table] AS [Extent1] CROSS JOIN (SELECT MAX([Extent2].[Column

Generated SQL with PredicateBuilder, LINQPad and operator ANY

一笑奈何 提交于 2019-12-01 11:14:01
I previously asked a question about chaining conditions in Linq To Entities. Now I use LinqKit and everything works fine. I want to see the generated SQL and after reading this answer , I use LinqPad . This is my statement: var predProduct = PredicateBuilder.True<Product>(); var predColorLanguage = PredicateBuilder.True<ColorLanguage>(); predProduct = predProduct.And(p => p.IsComplete); predColorLanguage = predColorLanguage.And(c => c.IdColorEntity.Products.AsQueryable().Any(expr)); ColorLanguages.Where(predColorLanguage).Dump(); The code works in VS2008, compile and produce the correct result

Generated SQL with PredicateBuilder, LINQPad and operator ANY

南笙酒味 提交于 2019-12-01 09:22:49
问题 I previously asked a question about chaining conditions in Linq To Entities. Now I use LinqKit and everything works fine. I want to see the generated SQL and after reading this answer, I use LinqPad. This is my statement: var predProduct = PredicateBuilder.True<Product>(); var predColorLanguage = PredicateBuilder.True<ColorLanguage>(); predProduct = predProduct.And(p => p.IsComplete); predColorLanguage = predColorLanguage.And(c => c.IdColorEntity.Products.AsQueryable().Any(expr));