Adding where clause to entity statement c#

Mike Miller
Mike Miller used Ask the Experts™
on
I'm trying to add a where clause here but not sure how or where to do it. I want to iterate through each record where...

            
using (var db = new PTO_SystemEntities())
            {
                var pto = db.PTO_REQUEST;
                foreach (var i in pto)
                {
...
                }
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Enthusiast
Commented:
Here is a simple query you could use:

using (var db = new PTO_SystemEntities())
{
	var pto = db.PTO_REQUEST
		.Where(pto => pto. == ?)
		.Select(pto => pto)
		.ToArray();
}

Open in new window


You will need to fill in the blanks to ensure that your query works. In the where clause you will have to add the property onto the pto. to filter on, plus replace the question mark with whatever you want to compare to.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial