0

I have a form with some indexes based on a document type.

I want to build my linq-to-sql query based on those index. The user might fill just some indexes or all of then.

I would need somenthing like that

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();

This built string should be buit early in the code something like

field1 == a and field2 == b

Is this possible?

1
  • 2
    I've read your question 5 times and I still can't understand it. Consider rephrasing. Commented Dec 20, 2012 at 1:58

1 Answer 1

1

Your goal is to create expression dynamicaly, as far as I can see. And there are no way just to put string in linq query and make it work in simple linq world - that's the bad news. But I also have a good news for you - there are some way exist to create your query dynamicaly:expression tree, dynamic LINQ.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.