0

ドキュメントタイプに基づいたいくつかのインデックスを持つフォームがあります。

これらのインデックスに基づいてlinq-to-sqlクエリを作成したいと思います。ユーザーは、一部のインデックスのみ、またはそのすべてを入力する場合があります。

私はそのようなものが必要になります

Gedi.Models.OperacoesModel.indexMatrix[] IndexMatrixArr = (from a in context.sistema_Documentos
join b in context.sistema_Indexacao on a.id equals b.idDocumento
join c in context.sistema_Indexes on a.idDocType equals c.id
join d in context.sistema_DocType_Index on c.id equals d.docTypeId

where d.docTypeId == idTipo and "BUILT STRING" 

orderby b.idIndice ascending
select new Gedi.Models.OperacoesModel.indexMatrix {
idDocumento = a.id,
idIndice = b.idIndice,
valor = b.valor
}).Distinct().ToArray();

このビルドされた文字列は、コードの早い段階で次のようになります。

field1==aおよびfield2==b

これは可能ですか?

4

1 に答える 1

1

あなたの目標は、私が見る限り、動的に表現を作成することです。そして、文字列をlinqクエリに入れて、単純なlinqの世界で機能させる方法はありません。これは悪いニュースです。ただし、朗報もあります。クエリを動的に作成する方法がいくつかあります。式ツリー動的LINQです。

于 2012-12-20T02:22:28.260 に答える