2011-08-10 8 views
0

以下のクエリでエラーが発生します。認識されない式ノード:linqを使用する場合のListInit

認識できない式ノード: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(); 
+0

これはlinq to sqlですか? –

答えて

3

このラインはあなたの問題です:

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

配列にList<OrderAttribute>から変更提案します。これは実行時に機能しますか?

OrderAttributes = new DataLayer.OrderAttribute[]{ 
+0

それはうまくいった。その少し醜いですが、私は一番上にOrderAttributesを配列に入れてからリストに戻しました。 LINQはリストをサポートしていませんか? –

+0

リストをサポートしているのは間違いなく、インライン初期化ではなく、リストを使用しようとしています。 LINQ To SQLを使用していると思われますが、正しいですか?この問題の別の例があります:http://bit.ly/n1lQqN –

+0

はい、私はlinqをSQLに使用しています –

関連する問題