带有连接的EF 4.1 ExecuteStoreQuery

时间:2012-02-06 09:43:16

标签: entity-framework entity-framework-4 entity-framework-4.1

是否可以将带有连接结果的ExecuteStoreQuery映射到域对象?

即。我们有2个域对象

public class Customer
{
    public virtual int Id { get; set; }
    public virtual string Name { get; set; }
    public virtual ICollection<Order> Orders { get; set; }
}

public class Order
{
    public virtual int Id { get; set; }
    public virtual string Description { get; set; }
    public virtual int CustomerId { get; set; }
    public virtual Customer Customer { get; set; }
}

现在如果我将运行此查询:

 string query = "select * from Order as Order 
    inner join Customer as Customer on Order.CustomerId = Customer.Id 
    where freetext(Order.Description, 'something')";
_objectContext.ExecuteStoreQuery<Order>(query);

结果将是所有客户设置为null的订单集合。 我该如何解决这个问题?

谢谢!

0 个答案:

没有答案