Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I add two parameters to an entity query?  (asp.net)

Posted on 2014-07-19
5
Medium Priority
?
248 Views
Last Modified: 2014-07-20
How would I add a second WHERE parameter to this code? It works with the one, but i need a second, for Licensed .
      
string F = "Female";
string L = "licensed ";
 var HR = OE.tbl_Dept.Where(d => d.Gender.Equals(F));

DeptGrid.DataSource = HR.ToList();
        DeptGrid.DataBind();

Open in new window

0
Comment
Question by:bmanmike39
  • 2
  • 2
5 Comments
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 40206958
try to add "And"

var HR = OE.tbl_Dept.Where(d => d.Gender.Equals(F) and your conditions come here);
0
 

Author Comment

by:bmanmike39
ID: 40206962
Doesn't work, error on the And.
0
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 40207361
Hi bmanmike39;

Try it like this. Make sure that I used the correct column name Licensed in the query. Also in your post you had an extra space in the declaration of the variable L at the end.

string F = "Female";
string L = "licensed";
var HR = OE.tbl_Dept.Where(d => d.Gender.Equals(F) && d.Licensed.Equals(L) );

DeptGrid.DataSource = HR.ToList();
DeptGrid.DataBind();

Open in new window

0
 

Author Closing Comment

by:bmanmike39
ID: 40207454
Thanks,  just what i was looking for.
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 40207456
Not a problem bmanmike39, glad to be of help.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline

772 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