How do I add two parameters to an entity query?  (

Posted on 2014-07-19
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();

Open in new window

Question by:bmanmike39
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
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);

Author Comment

ID: 40206962
Doesn't work, error on the And.
LVL 63

Accepted Solution

Fernando Soto earned 500 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();

Open in new window


Author Closing Comment

ID: 40207454
Thanks,  just what i was looking for.
LVL 63

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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