linq-method-syntax

Cannot implicitly convert type 'System.Collections.Generic.List<AnonymousType#1>' to 'System.Linq.IQueryable<AnonymousType#2>'

时间秒杀一切 提交于 2019-12-25 07:15:24
问题 This query is being compiled without errors: var _entityList = context.customer .Join(context.applications, cust => cust.cust_id, app => app.cust_id, (cust, app) => new { customer = cust, application = app }) .Join(context.advices, cust => cust.application.app_id, sa => sa.app_id, (cust, sa) => new { customer = cust, advice = sa }) .GroupBy(g => new { g.customer.customer.cust_id, g.customer.customer.cust_code, g.customer.customer.cust_name }) .Select(g => new { cust_id = g.Key.cust_id, cust

LINQ group by date - include empty days WITHOUT using join

这一生的挚爱 提交于 2019-12-18 09:39:13
问题 Using C#, NHibernate, NHibernate to LINQ. Using NHibernate to LINQ, I do not have the JOIN functionality. I can not use QueryOver either. I have a LINQ query that counts the amount of Leads and Sales. This table only creates when a new lead or sale is done, so some days there is no row inserted. Doing the following query works var query3 = query2.AsEnumerable() .Where(x => x.Created <= toDate.Value && x.Created >= fromDate.Value) .GroupBy(x => x.Created.Date) .Select(g => new ReferrerChart {

LINQ group by date - include empty days WITHOUT using join

女生的网名这么多〃 提交于 2019-11-29 16:51:28
Using C#, NHibernate, NHibernate to LINQ. Using NHibernate to LINQ, I do not have the JOIN functionality. I can not use QueryOver either. I have a LINQ query that counts the amount of Leads and Sales. This table only creates when a new lead or sale is done, so some days there is no row inserted. Doing the following query works var query3 = query2.AsEnumerable() .Where(x => x.Created <= toDate.Value && x.Created >= fromDate.Value) .GroupBy(x => x.Created.Date) .Select(g => new ReferrerChart { Date = g.Key.Date, LeadsCount = g.Count(x => !x.IsSale), SalesCount = g.Count(x => x.IsSale) }); but

LINQ to Entities does not recognize my method

佐手、 提交于 2019-11-28 06:02:19
问题 I want to convert date and time to Persian in LINQ select but linq can not recognize my method : LINQ to Entities does not recognize the method 'System.String toPersianDateTime(System.DateTime)' method, and this method cannot be translated into a store expression. How can I change my method to LINQ compatible? My method : public static string toPersianDateTime(DateTime dt) { PersianCalendar pc = new PersianCalendar(); string pDateTime = pc.GetYear(dt).ToString() + "/" + pc.GetMonth(dt)