Click here to Skip to main content
13,633,429 members

Visual Studio 2015 & .NET 4.6

 
GeneralRe: How to query database using Entity to SQL Pin
Richard Deeming12-Apr-13 3:50
professionalRichard Deeming12-Apr-13 3:50 
GeneralRe: How to query database using Entity to SQL Pin
ADSCNET12-Apr-13 4:03
memberADSCNET12-Apr-13 4:03 
GeneralRe: How to query database using Entity to SQL Pin
ADSCNET12-Apr-13 6:35
memberADSCNET12-Apr-13 6:35 
GeneralRe: How to query database using Entity to SQL Pin
Richard Deeming12-Apr-13 7:14
professionalRichard Deeming12-Apr-13 7:14 
GeneralRe: How to query database using Entity to SQL Pin
ADSCNET12-Apr-13 7:34
memberADSCNET12-Apr-13 7:34 
GeneralRe: How to query database using Entity to SQL Pin
Richard Deeming12-Apr-13 8:17
professionalRichard Deeming12-Apr-13 8:17 
GeneralRe: How to query database using Entity to SQL Pin
ADSCNET12-Apr-13 9:26
memberADSCNET12-Apr-13 9:26 
GeneralRe: How to query database using Entity to SQL Pin
Richard Deeming12-Apr-13 12:34
professionalRichard Deeming12-Apr-13 12:34 
Taking the telephone as an example:
If Not String.IsNullOrWhiteSpace(Me.txtTelephone.Text) Then
    query = From employee In query Where employee.Telephone.Contains(Me.txtTelephone.Text)
End If

  • If you've not entered anything the txtTelephone box, you don't want to filter by telephone number, so we don't include that filter.
  • If you have entered something in the txtTelephone box, you only want to return records where the Telephone column is not null, and contains the text that you've entered.

If this code was executing in VB, and the Telephone property returned Nothing, you'd get a NullReferenceException when you tried to call the Contains method on it.

However, since you're using LINQ, the filter will be translated to SQL:
... And Telephone Like '%123456%'

In SQL, this will not generate an error if the Telephone column is null; it will just exclude that row from the results.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: How to query database using Entity to SQL Pin
ADSCNET13-Apr-13 3:06
memberADSCNET13-Apr-13 3:06 
GeneralRe: How to query database using Entity to SQL Pin
Richard Deeming15-Apr-13 1:27
professionalRichard Deeming15-Apr-13 1:27 
GeneralRe: How to query database using Entity to SQL Pin
ADSCNET15-Apr-13 1:52
memberADSCNET15-Apr-13 1:52 
Questiondeploy vsto Excel template in intranet Pin
wassim_mar2-Apr-13 0:16
memberwassim_mar2-Apr-13 0:16 
QuestionCrystal report groups Pin
Tufail Ahmad25-Mar-13 3:11
memberTufail Ahmad25-Mar-13 3:11 
Questionsnake game error, moving randomly. Pin
srinivasankrishnaa28-Feb-13 3:57
membersrinivasankrishnaa28-Feb-13 3:57 
AnswerRe: snake game error, moving randomly. Pin
Pete O'Hanlon28-Feb-13 4:04
protectorPete O'Hanlon28-Feb-13 4:04 
GeneralRe: snake game error, moving randomly. Pin
srinivasankrishnaa28-Feb-13 4:45
membersrinivasankrishnaa28-Feb-13 4:45 
AnswerRe: snake game error, moving randomly. Pin
ryanb3120-Mar-13 1:54
memberryanb3120-Mar-13 1:54 
AnswerRe: snake game error, moving randomly. Pin
Filipe Moreira de Oliveira17-May-13 15:58
professionalFilipe Moreira de Oliveira17-May-13 15:58 
QuestionCI in TFS Pin
nitin_ion20-Feb-13 23:29
membernitin_ion20-Feb-13 23:29 
QuestionThanking Mike Meinz Pin
srinivasankrishnaa20-Feb-13 5:00
membersrinivasankrishnaa20-Feb-13 5:00 
AnswerRe: Thanking Mike Meinz Pin
Richard MacCutchan20-Feb-13 5:35
mvpRichard MacCutchan20-Feb-13 5:35 
AnswerRe: Thanking Mike Meinz Pin
Sandeep Mewara20-Feb-13 6:27
mvpSandeep Mewara20-Feb-13 6:27 
Questionfind sentence with regular expression in VS Pin
Elham M18-Feb-13 21:25
memberElham M18-Feb-13 21:25 
AnswerRe: find sentence with regular expression in VS Pin
Pete O'Hanlon18-Feb-13 22:24
protectorPete O'Hanlon18-Feb-13 22:24 
Questionprocessor id Pin
srinivasankrishnaa16-Feb-13 3:38
membersrinivasankrishnaa16-Feb-13 3:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Cookies | Terms of Service
Web03-2016 | 2.8.180712.1 | Last Updated 26 Mar 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid