Solved

How to pass null values  to test condition in where clause using LINQ

Posted on 2009-04-03
3
395 Views
Last Modified: 2013-11-11
my queries are

1) select * from tablename where col == null

2) select * from tablename where col  != null

i need this queries in LINQ.
0
Comment
Question by:ravindra333
3 Comments
 
LVL 21

Accepted Solution

by:
naspinski earned 250 total points
ID: 24059987

var results1 = from p in YourDataContext.tablename where p.col == null select p;
 

var results2 = from p in YourDataContext.tablename where p.col != null select p;

Open in new window

0
 
LVL 62

Assisted Solution

by:Fernando Soto
Fernando Soto earned 250 total points
ID: 24061162
Hi ravindra333;

You can also use this form in Linq, The database must be a Microsoft SQL server in both solution post :

            var result1 = DataContext.TableName.Where(c => c.col  == null);
            var result2 = DataContext.TableName.Where(c => c.col  != null);

Where the c in the Where clause can be any name of your choosing.

Fernando
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now