我在OData中使用Entity Framework,有两个这样的类:
public class Foo {
public virtual B b {get; set;}
}
public class B {
public int c {get; set;}
}
从dbSet执行这样的查询:
var query = Foos.Where(x => x.id == 1)
拥有以下oData:(B/c eq 3)
对IQueryable结果(查询)应用过滤器:
FilterQueryOption filter = new FilterQueryOption(queryFilter, ODataQueryContext);
var q = filter.ApplyTo(query, new ODataQuerySettings());
使用消息抛出oDataException:无法在类型Foo
上找到名为b的属性答案 0 :(得分:1)
public class Foo
{
[ForeignKey("B")]
public int c { get; set; }
public virtual B B { get; set; }
}