mercredi 28 octobre 2015

Is it possible to add if-else condition in Repository Pattern Query C#?

Is it possible to add if-else condition in Repository Pattern Query, if yes, then how?

I have the following query :

int Id=3;
IList<Demo> obj= repository.Query<Demo>(p => p.id == Id).ToList<Demo>();

I want the condition in the same query if Id is not equal to 0 then only

p => p.id == Id

else it should not be included in query, Is it possible?

I want something like this:

IList<Demo> obj= repository.Query<Demo>(Id != 0?p => p.id == Id:" ").ToList<Demo>();

Aucun commentaire:

Enregistrer un commentaire