2016-11-30 67 views
0

我有一個名爲DashboardGroupData「指定類型成員沒有在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; } 
} 

類,我有以下實體查詢:

     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到實體只有初始化,實體成員和實體導航屬性都支持」錯誤:

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

直接寫成一個SQL查詢同樣的查詢作品完美,在LINQPad 5做了以上的查詢,使用相同的連接和實體模型的應用。

我試圖重新命名的分貝場序的東西,這不是一個SQL保留字 - 但它並沒有任何區別。

一條線索:如果我將第一個查詢(「groupConsignmentList =」)並將其轉換爲列表,則在列表的每個成員中,Sequence的值爲零 - 而在LINQPad 5中,它會生成正確的值。

在.NET Framework 4.6

回答

0

的問題是,我還沒有意識到,在代碼查詢groupConsignmentList的多於一個的任務 - 和我的序列添加到一個不在這種情況下使用的那個。

相關問題