2016-11-30 5 views
0
で働く

私は 「指定された型のメンバーは、エンティティへのLINQでサポートされていない」しかしLINQPad

public class DashboardGroupData 
{ 
    public int ConsignmentID {get;set;} 
    public DateTime ActualManifestDate {get;set;} 
    public DateTime PlannedLatestDeliveryDateTime {get;set;} 
    public DateTime PlannedEarliestDeliveryDateTime {get;set;} 
    public DateTime PlannedEarliestCollectionDateTime { get; set; } 
    public string Status {get;set;} 
    public int ServiceLevelID {get;set;} 
    public double PalletWeight {get;set;} 
    public int MaxMove {get;set;} 
    public int LastMove { get; set; } 
    public int PalletStatusID { get; set; } 
    public int Sequence { get; set; } 
    public int RequestDepotID { get; set; } 
    public int CollectionDepotID { get; set; } 
    public bool Collection { get; set; } 
} 

DashboardGroupData

と呼ばれるクラスを持つI次のエンティティのクエリを持っている:

     groupConsignmentList = (from d in connectDB.vwDepotDashboards 
              where depotAndSubDepots.Contains(d.DeliveryDepotID) 
              && !incomplete.Contains(d.Status) 
              && (!depotAndSubDepots.Contains(d.CollectionDepotID) || d.CustDirectToHub) 
              && d.Sequence < (int)PalletStatusSequence.ICC 
              && d.ActualManifestDate > validWindow 
              && d.TransitHubID == hubID 
              select new Models.DashboardGroupData() 
              { 
               ConsignmentID = d.ConsignmentID, 
               ActualManifestDate = d.ActualManifestDate, 
               PlannedLatestDeliveryDateTime = d.PlannedLatestDeliveryDateTime, 
               PlannedEarliestDeliveryDateTime = d.PlannedEarliestDeliveryDateTime, 
               Status = d.Status, 
               PlannedEarliestCollectionDateTime = d.PlannedEarliestCollectionDateTime, 
               ServiceLevelID = d.ServiceLevelID, 
               PalletWeight = d.PalletWeight, 
               PalletStatusID = d.PalletStatusID, 
               Sequence = d.Sequence, 
               Collection = d.Collection, 
               RequestDepotID = d.RequestDepotID, 
               MaxMove = connectDB.PalletMovements.Where(c => c.CreatedDateTime < manifestDayEnd && c.PalletID == d.PalletID && !(c.PalletMovementTypeID > 12 && c.PalletMovementTypeID < 19)).Max(c => (int?)c.PalletMovementTypeID) ?? 0 
              }); 

私がしよう(下の)クエリを実行します。「指定された型メンバーは、LINQ to Entitiesでサポートされていません。イニシャライザ、エンティティメンバ、およびエンティティのナビゲーションプロパティのみがサポートされています」エラー:

var test = groupConsignmentList.Where(c => c.Sequence > 650 && c.Sequence < 1000).Select(c => c.ConsignmentID).ToList(); 

SQLクエリとして直接書き込まれた同じクエリは、アプリケーションと同じ接続およびエンティティモデルを使用して、LINQPad 5で上記のクエリと同様に完全に動作します。

私はdb内のフィールドの名前をSQLの予約語ではないものに変更しようとしましたが、何の違いもありませんでした。

1つのヒント:最初のクエリ(「groupConsignmentList =」)を使用してリストの各メンバーに変換すると、シーケンスの値は0になりますが、LINQPad 5では正しい値が生成されます。

.NET Frameworkが4.6

答えて

0

問題は、私はコードでgroupConsignmentListにクエリの複数の割り当てがあることに気づいていなかったことであった - であり、私はシーケンスを追加した一つがなかったですこの場合に使用されるものです。

関連する問題