2016-04-02 6 views
0

私はこのモデル(モデルはより多くのですが、今では重要ではありません)多対多テーブル間の関係の場合、エンティティFraemworkで交差を取得する方法は?

enter image description here

は、私はいくつかの注釈を持っていると私は、これらの注釈でどのように機能するか、すべてのユーザーを取得したいと思いますが、私はこれを取得例外(「タイプ 『DataBase.Annotation』の一定値を作成できません。 のみプリミティブ型または列挙型はこのコンテキストでサポートされています。」)、使用次のコード

TextCorporaEntities TextCorporaContext = new TextCorporaEntities(); 
List<DataBase.Annotation> annotations = //annotations which I used 
//I get the exception here 
var UserAnnotationsResult = TextCorporaContext.Annotation_User. 
     Where(x => annotations. 
      Contains(x.Annotation)); 

私はこのコードを使用することができ、それは生産的ではありません

List<Annotation_User> listResult = new List<Annotation_User>(); 
foreach (var x in annotations) 
{ 
    listResult.Concat(TextCorporaContext.Annotation_User.Where(y=>y.AnnotationId == x.Id)); 
} 

注釈を使用したすべてのユーザーを取得するにはどうすればよいですか? AccessTypeがReadOrWriteと等しいいくつかの注釈を使用したすべてのユーザーを取得する方法(モデルでは文字列に保存されます)?あなたが使用することができます

答えて

2

は、私は、これは

var annotationsIds = annotations.Select(a => a.AnnotationId) 
var UserAnnotationsResult = TextCorporaContext.Annotation_User. 
    Where(x => annotationsIds. 
     Contains(x.Annotation.AnnotationId)); 
を動作するはずだと思うのプリミティブ

にのみ含まれてい

関連する問題