RE: How to filter with LINQ?
- From: v-wywang@xxxxxxxxxxxxxxxxxxxx ("Wen Yuan Wang [MSFT]")
- Date: Tue, 13 May 2008 07:52:32 GMT
Hello Juan,
It seems like you want empty textbox NOT to be taken account in the where
clause, correct? If I misunderstood anything again, please don't hesitate
to correct me.
One way is to create Linq Query dynamically by Express Tree. But, the code
will be hard to maintain and read. My suggestion is that we can check the
textbox value in the conditional operator (?:). It returns one of two
values depending on the value of a Boolean expression. eg:
var someAdministrators = from a in db.ADMINISTRATORs
where
(textbox1.value==""?a.c1==textbox1.value:true)
&&
(textbox2.value==""?a.c2==textbox2.value:true)
&&
(textbox3.value==""?a.c3==textbox3.value:true)
select a;
Hope this helps. Please try the above method and let me know if this is
what you need. If there is anything unclear, please also feel free to let
us know. We are glad to assist you.
Have a great day,
Best regards,
Wen Yuan
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- References:
- How to filter with LINQ?
- From: Juan Dent
- RE: How to filter with LINQ?
- From: "Wen Yuan Wang [MSFT]"
- RE: How to filter with LINQ?
- From: Juan Dent
- How to filter with LINQ?
- Prev by Date: RE: Unable to add Web Reference in Visual Studio 2008 on Win 2003
- Next by Date: RE: Dynamic controls and accessing them by TabOrder
- Previous by thread: RE: How to filter with LINQ?
- Next by thread: Sending email
- Index(es):
Relevant Pages
|