2011-09-16 5 views
1
public IEnumerable<CommodityPrice> GetAllTimeFrameDaily() 
    { 
     return _dbprice.ExecuteQuery<CommodityPrice>("SELECT MIN(CommodityPrice.dtm_Date),MAX(CommodityPrice.dtm_Date) FROM CommodityPrice WHERE (CommodityPrice.int_FrequencyId = 1) and int_MarketLocationId in (SELECT [int_LocationId] FROM [Location] where int_LocationTypeId=4 and int_ParentLocationId in (SELECT [int_LocationId] FROM [Location] where int_LocationTypeId=2 and int_ParentLocationId in (SELECT int_LocationId FROM [Location] where int_LocationTypeId = 1 and vcr_LocationEn='Pakistan')))"); 
    } 

私はこのエラーが発生していますThe required column 'int_CommodityPriceId' does not exist in the results.これを行う理由は何ですか? (私のdbmlファイルにはCommodityPriceId列があります)。私は、LINQ to SQLのを使用していますし、SQL Server必須の列 'int_CommodityPriceId'は結果に存在しません。 linq to sql

commodityprice 

int_CommodityPriceId bigint Unchecked 
int_CommodityId bigint Checked 
int_SourcesId int Checked 
int_MarketLocationId int Checked 
int_FrequencyId int Checked 
flt_Price float Checked 
flt_PriceUSD float Checked 
+1

何 'CommodityPrice'のように見えるのでしょうか?しかしメッセージ*自体は正しかった - 確かに、 'int_CommodityPriceId'は結果には存在しません - 実際には、結果カラムのどれもが名前を持っていません.... –

答えて

2

で実行されているファイルでそれを2010.running対このコードはCommodityPriceエンティティに結果を割り当てるしようとしています。 これを実行するには、CommodityPriceエンティティ列のプロパティで定義されているすべての列を返す必要があります。クエリではいずれも返されません。

この2つのフィールドを返すだけなら、 「..

TimeFrame 
dte_CommodityPriceMinDate datetime Unchecked 
dte_CommodityPriceMaxDate datetime Checked 

をわずか2日付フィールドを含む新しいエンティティを必要とするでしょうし、クエリではなく、これを移入する必要があります

public IEnumerable<TimeFrame> GetAllTimeFrameDaily() 
    { 
     return _dbprice.ExecuteQuery<TimeFrame>("SELECT MIN(CommodityPrice.dtm_Date) AS dte_CommodityPriceMinDate ,MAX(CommodityPrice.dtm_Date) AS dte_CommodityPriceMaxDate FROM CommodityPrice WHERE (CommodityPrice.int_FrequencyId = 1) and int_MarketLocationId in (SELECT [int_LocationId] FROM [Location] where int_LocationTypeId=4 and int_ParentLocationId in (SELECT [int_LocationId] FROM [Location] where int_LocationTypeId=2 and int_ParentLocationId in (SELECT int_LocationId FROM [Location] where int_LocationTypeId = 1 and vcr_LocationEn='Pakistan')))"); 
    } 
関連する問題