【发布时间】:2015-04-16 19:35:44
【问题描述】:
我有一个 OData 方法,我想从该方法返回一个实体列表。
这是我的代码
public async Task<IHttpActionResult> LoadSpecimenMachinings([FromODataUri] Int32 key)
{
if (!ModelState.IsValid)
return BadRequest(ModelState);
Int32 stage = 1;
string csvSpecimenCodes = "S0,S1,S2";
List<Machining> machinings = null;
var machiningResult = db.LoadSpecimenMachinings(key, stage, csvSpecimenCodes);
machinings = (from machining in machiningResult select machining).ToList();
return Created(machinings);
}
当我在return Created(machinings); 行中返回实体列表(加工是我的实体框架模型中的一个实体)时,我收到以下错误:
"message":" is not an entity type. Only entity types are supported.",
"type":"System.InvalidOperationException"
据我了解,不幸的是Created 无法接收实体列表作为参数。
有什么方法可以在 OData 中返回实体列表和创建的 HTTP 代码?
我正在使用 OData V3 和实体框架 6。
【问题讨论】:
标签: c# entity-framework odata