2011-08-31 8 views
2

EFで適切な結果を返すようには見えない含めると、私は次のクエリでの問題に実行していますよ上記のインクルードに示されているように、注文明細のサブリスト(user-> orders-> order_line_itemsのようなもの)のサブリストを含むユーザーのリストを返すことができますが、ToTraceStringと呼ぶとユーザーのリストのみを返します。LINQのクエリ私はEntity Frameworkの4.0を使用しています4.0

これまでにIncludeを使用しましたが、何も問題はありませんが、今回は間違っています。

+0

どのようにusers'と '' orders_assigned'間のモデル内の関係を設定していますか?そこに問題があるようです。 – newdayrising

+0

関係はforiegnキーによってEFで定義されています - 何らかの理由で適切な結果を返すincludeを使用して他のlinqクエリを実行しましたが、これはthoではありません – 99823

答えて

1

試してみてください。

IQueryable<user> users = ((ObjectQuery<user>) 
    from u in Entities.users 
    from o in u.orders_assigned 
    where 
     o.status.Equals((int)OrderStatus.ReadyForInvestigation) && 
     o.assigned_to_user_id != 0 
    from oli in o.order_line_items 
    where 
     oli.line_item_type.Equals("service") || 
     oli.line_item_type.Equals("package_service") 
    select u).Include("orders_assigned").Include("orders_assigned.order_line_items"); 

Explanation here.

関連する問題