我使用mvc application
和simple OData
从两个表中检索值。
创建了ODataClient的对象
ODataClient客户端=新ODataClient(" http://localhost:65556/Dev");
想要从两个表中检索值,就像在Sql中一样,我们只需要执行以下操作
select * from [Table1] t1 join [Table2] t2
on t1.Id = t2.Id
where t1.[Title] = 'US'
现在在SimpleOdata中,我不知道一个表的两个表操作,我们可以简单地执行类似下面的操作
ODataClient client = new ODataClient("http://localhost:64576/Dev");
var packages = await client
.For<Table1>()
.Filter(x => x.Title == "US")
.FindEntriesAsync();
foreach (var package in packages)
{
return package.Title;
}
return "test";
如何更正两个表的上述表达式?
答案 0 :(得分:1)
我想你应该使用扩展功能。看这里http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/using- $ select, - $ expand,-and- $ value
答案 1 :(得分:0)
ODataClient client = new ODataClient("http://localhost:64576/Dev");
var packages = await client
.For<Table1>()
.Expand(x => x. Table2)
.Filter(x => x.Title == "US")
.FindEntriesAsync();
foreach (var package in packages)
{
return package.Title;
}
return "test";