Advertisement

05.13.2008 at 10:01PM PDT, ID: 23400318
[x]
Attachment Details

Return row from Linq query even if there is no data

Asked by GMSDev in Language Integrated Query - LINQ, Microsoft Visual Basic.Net, Microsoft Visual C#.Net

Tags: Linq, C#, SQL

I have the Linq query below and I need to modify it so that it always returns a row even if the query returns 0 rows.  Is there a way to do that?  If there is no result from the query, I need it to still have a row of nulls or something like that.Start Free Trial
1:
2:
users = from u in db.Users 
where SqlMethods.Like(u.User_Username, txtUserName.Text.Trim() + "%") select u;
[+][-]05.14.2008 at 09:52AM PDT, ID: 21566206

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 10:20AM PDT, ID: 21566511

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 11:41PM PDT, ID: 21571088

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Language Integrated Query - LINQ, Microsoft Visual Basic.Net, Microsoft Visual C#.Net
Tags: Linq, C#, SQL
Sign Up Now!
Solution Provided By: naspinski
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05.15.2008 at 11:11AM PDT, ID: 21576558

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.19.2008 at 12:28AM PDT, ID: 21595724

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.19.2008 at 06:55PM PDT, ID: 21603031

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 08:36AM PDT, ID: 21607193

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628