RE: How to filter with LINQ?

Tech-Archive recommends: Fix windows errors by optimizing your registry



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.

.



Relevant Pages

  • Re: Temp file collision when building with csc.exe
    ... If you have any questions or concerns, please don't hesitate to let me know. ... Microsoft Online Community Support ... You can send feedback directly to my manager at: ... "Sune Foldager" wrote in message ...
    (microsoft.public.dotnet.framework)
  • Re: Linked Server Security
    ... If you encounter any difficulties, please do not hesitate to let me ... Microsoft Online Community Support ... Please feel free to let my manager ...
    (microsoft.public.sqlserver.security)
  • RE: Moving SQL 2000 Database to SQL 2005
    ... If you need me further explanation, please do not hesitate to let ... Microsoft Online Community Support ... Please feel free to let my manager ...
    (microsoft.public.sqlserver.server)
  • Re: Style trigger not firing in wpf app
    ... Thank you for your confirmation. ... If you have any other questions in the future, please don't hesitate to ... Microsoft Online Community Support ... You can send feedback directly to my manager at: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Apply a control template to a thumb with c#
    ... Thank you for your confirmation! ... If you have any other questions in the future, please don't hesitate to ... Microsoft Online Community Support ... You can send feedback directly to my manager at: ...
    (microsoft.public.dotnet.languages.csharp)