?
Solved

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

Posted on 2009-04-03
3
Medium Priority
?
406 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
2 Comments
 
LVL 21

Accepted Solution

by:
naspinski earned 1000 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 64

Assisted Solution

by:Fernando Soto
Fernando Soto earned 1000 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

840 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