score:2
First part of your question:
var projectIDs = db.ProjectMembers.Where(c=> c.UserID=u.UserID).select(pm=>pm.ProjectID) ;
2nd part:
if you are using Entity Framework, you should see a property called (project) for every entity of your ProjectMembers list, you can simply ignore my first part of this answer and go directly with this one
var projectsList = db.ProjectMembers.Where(c=> c.UserID=u.UserID).select(pm=>pm.Project) ;
the property may have a different name, give it a try and let me know what happened.
note: that if the retrieved projects were null, then your Entity framework is working wth Eager loading (Google it). so in order to let the Entity framework generate the proper SQL syntax to retrieve the projects data, add an Include() to your query as the following:
var projectsList = db.ProjectMembers.Where(c=> c.UserID=u.UserID).Include("Projects").select(pm=>pm.Project) ;
Source: stackoverflow.com
Related Articles
- LINQ query returns old results when source list is re-initialized
- c# Linq or code to extract groups from a single list of source data
- LINQ query to return distinct field values from list of objects
- LINQ query to find if items in a list are contained in another list
- Linq query list contains a list
- Linq query between two list objects
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- Linq Query Dictionary where value in List
- Query a List of List of Items in LINQ c#
- Linq query to filter id inside a list of list c#
- Dynamically build select list from linq to entities query
- Linq query to get the distinct values in a list
- Return Linq Query into a List of KeyValuePair's
- Linq query to exclude from a List when a property value of List of different type are equal?
- LINQ query to split an ordered list into sublists of contiguous points by some criteria
- Using Linq query inside List<T>.AddRange to conditionally add elements from one list to another
- Entity Framework Linq Query to List - Error when using contains: Only primitive types, enumeration types and entity types are supported
- Linq query a List of objects containing a list of object
- Get first item in list from linq query
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Dynamic Linq query Contains List
- Linq to entities - SQL Query - Where list contains object with 2 properties (or more)
- How to write a LINQ to Entities query with List in a "WHERE" condition
- Linq query using list or array of ids
- linq query group by in a list of strings
- LINQ how to query if a value is between a list of ranges?
- Nested LINQ query to select 'previous' value in a list
- Linq query to merge distinct items in a list
- LINQ Source Code Available
- List of all LINQ query expression keywords?
- comma separated list items with brackets in linq
- linq search functionality skip where clause if null?
- show one list inside another one list of Resful api.
- Converting a Predicate<T> to a Func<T, bool>
- LINQ grouping in object
- Changing the response type of WEB API
- c# Lambda, LINQ .... improve this method
- General method to select first row from every group in DataTable, give a List of grouping column
- Linq to select same datatype from multiple tables
- How do I write this LINQ query in fluent syntax?
- EF 4: Removing child object from collection does not delete it - why?
- LINQ Query for sum and aggregate data
- Convert my SQL to LINQ
- How to check DBNull value in Linq query results
- How can I get two different aggregates in a single LINQ?
- Adding optional where parameter to query based linq query
- How to know if Array FileInfo[] contains a file
- C# Linq Reading File into List
- C# LINQ/EF throwing invalid cast on property with value conversion
- How to copy a node xml and appended to the specified node using linq to XML