Solved

check for null in linq to sql

Posted on 2008-10-08
3
2,629 Views
Last Modified: 2013-11-11
If query one table in linq to sql; how can I check if one fileld (an image field set to binary in dbml) is null or empty.

So say something like this

var results = from p in mycontext
                    where p.ID == _itemId  && p.photograph <> null
                       select p.photograph ;    
0
Comment
Question by:mugsey
  • 2
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22667108
IS NOT NULL
instead of <> NULL
0
 

Author Comment

by:mugsey
ID: 22667124
Thanks but this does not let me

The photograph field of of type BYTE so I need to check if there is nothing in that field
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 22667137
please try this:

var results = from p in mycontext
                    where p.ID == _itemId  && p.photograph != null
                       select p.photograph ;     

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

810 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