使用linq时无法识别的表达式节点:ListInit

时间:2011-08-10 17:01:21

标签: c# linq

我收到以下查询的错误。

  

无法识别的表达式节点:ListInit'

一切看起来都很好,并遵守。

如果您需要datacontext或任何类的详细信息,请告诉我。有任何想法吗?

        rsp = (from r in db.btRequests
               join o in db.NewOrders.AsEnumerable()
               on r.ID equals o.RequestId
               join s in db.Status
               on r.Status equals s.ID.ToString()
               select new DataLayer.OrderResponse
               {
                   ID = "BT" + requestID,
                   OrderStatus = r.Status.ToString(),
                   PredictedActivationDate = ((r.Status == "3" || r.Status == "4" || r.Status == "5"
                   || r.Status == "6" || r.Status == "9") && o.CustomerRequiredDate.HasValue ? o.CustomerRequiredDate.Value.ToShortDateString() : ""),
                   City = o.City,
                   Dsl = o.dsl,
                   CustomerRef = o.CustomerRef,
                   Error = null,
                   Postcode = o.Postcode,
                   OrderAttributes = new List<DataLayer.OrderAttribute>(){
                       new DataLayer.OrderAttribute(){Name = "MAC", Value= o.Mac},
                       new DataLayer.OrderAttribute(){Name = "ServiceId", Value= o.ServiceId},
                       new DataLayer.OrderAttribute(){Name = "ContactName", Value= o.ContactName},
                       new DataLayer.OrderAttribute(){Name = "ContactTelephone", Value= o.ContactTelephone},
                       new DataLayer.OrderAttribute(){Name = "ContactEmail", Value= o.ContactEmail},
                       new DataLayer.OrderAttribute(){Name = "ContactSecondryTelephone", Value= o.ContactSecondryTelephone},
                       new DataLayer.OrderAttribute(){Name = "ContactFirstName", Value= o.ContactFirstName},
                       new DataLayer.OrderAttribute(){Name = "AddressRef", Value= o.AddressRef},
                       new DataLayer.OrderAttribute(){Name = "AppointmentRef", Value= o.AppointmentRef},
                       new DataLayer.OrderAttribute(){Name = "LineStatus", Value= o.LineStatus},
                       new DataLayer.OrderAttribute(){Name = "Note", Value= o.Note},
                       new DataLayer.OrderAttribute(){Name = "AccessTechnology", Value= o.AccessTechnology},
                       new DataLayer.OrderAttribute(){Name = "StabilityOption", Value= o.StabilityOption},
                       new DataLayer.OrderAttribute(){Name = "TrafficWeighting", Value= o.TrafficWeighting},
                       new DataLayer.OrderAttribute(){Name = "MaintenanceCategory", Value= o.MaintenanceCategory}
                       }
               }).FirstOrDefault(); 

1 个答案:

答案 0 :(得分:3)

怀疑这一行是你的问题:

 OrderAttributes = new List<DataLayer.OrderAttribute>(){

建议从List<OrderAttribute>更改为数组。这是否在运行时工作?

 OrderAttributes = new DataLayer.OrderAttribute[]{