The required column 'int_CommodityPriceId' does not exist in the results. linq to sql
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_开发者_如何学CLocationTypeId=2 and int_ParentLocationId in (SELECT int_LocationId FROM [Location] where int_LocationTypeId = 1 and vcr_LocationEn='Pakistan')))");
}
i am getting this error The required column 'int_CommodityPriceId' does not exist in the results.
any idea why it is doing this. (my dbml file do have the CommodityPriceId column). i am using linq to sql and vs 2010.running it in running file in sql server
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
This code is attempting to assign the results to a CommodityPrice
entity.
In order to do this, it needs to return all of the columns defined in the CommodityPrice
entity column properties.. Your query doesn't return ANY of them..
If you just want to return these 2 fields, you'll need a new entity containing just 2 date fields..
TimeFrame
dte_CommodityPriceMinDate datetime Unchecked
dte_CommodityPriceMaxDate datetime Checked
and the query should populate this instead:
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')))");
}
精彩评论