0

次のようなコードを実行する必要があります。

Dictionary<Int64, List<Int64>> types;
// initialization of dictionary
results = (from m in d.Linq() 
           where (filter.Types.Any(x =>
                                 x.Key == m.DocumentType.Code
                                 && x.Value.Contains(m.DocumentPurpose.Code)
                                )
                 )
           select m 
          ).ToList();

このテストを実行したとき、私は受け取りましSystem.NullReferenceExceptionた。typesしかし、オブジェクトはそうではなくnull、少なくとも1つのペア(キー:26、値:2、4)が含まれていると確信しています。

LINQはこのAny()式をSQLに変換できないと思います。このクエリを書き直すにはどうすればよいですか?

4

1 に答える 1

2

これを試して:

results = (from m in d.Linq() 
           where (m.DocumentType != null &&
                  m.DocumentPurpose != null &&
                  filter.Types.Any(x =>
                                 x.Key == m.DocumentType.Code
                                 && x.Value.Contains(m.DocumentPurpose.Code)
                                )
于 2012-08-08T05:32:12.140 に答える