必需的列“int_CommodityPriceId”结果中不存在。 LINQ 到 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_LocationTypeId=2 and int_ParentLocationId in (SELECT int_LocationId FROM [Location] where int_LocationTypeId = 1 and vcr_LocationEn='Pakistan')))");
}
我收到此错误结果中不存在所需的列“int_CommodityPriceId”。
知道为什么要这样做。 (我的 dbml 文件确实有 CommodityPriceId 列)。我正在使用 linq to sql 和 vs 2010.在 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
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')))");
}
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此代码尝试将结果分配给
CommodityPrice
实体。为此,它需要返回
CommodityPrice
实体列属性中定义的所有列。您的查询不会返回其中任何列。如果您只想返回这 2 个字段,您将需要一个仅包含 2 个日期字段的新实体..
并且查询应填充此字段:
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..
and the query should populate this instead: