开发者

Unrecognized expression node: ListInit when using linq

开发者 https://www.devze.com 2023-03-27 17:55 出处:网络
I\'m getting an error for the below query. Unrecognized expression node: ListInit\' Everything looks fine to me and complies.

I'm getting an error for the below query.

Unrecognized expression node: ListInit'

Everything looks fine to me and complies.

Let me know if you need details of the datacontext or any of the classes. Any ideas?

        rsp = (from r in db.btRequests
     开发者_JAVA技巧          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(); 


Suspect this line is your problem:

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

Suggest changing from List<OrderAttribute> to an array. Does this work at runtime?

 OrderAttributes = new DataLayer.OrderAttribute[]{
0

精彩评论

暂无评论...
验证码 换一张
取 消