score:2
Accepted answer
public List<MyType> GetMyTypes(List<int> ids)
{
return (from myType in db.MyTypes
where ids.Contains(myType.Id)
select new MyType
{
MyValue = myType.MyValue
}).ToList();
}
score:1
Untested
public List<MyType> GetMyTypes(List<int> myIds) {
var x = from myType in db.MyTypes
where myIds.contains(myType.Id)
select new MyType {
MyValue = mytype.Myvalue
};
return x.ToList();
}
Source: stackoverflow.com
Related Articles
- How to get List of results from list of ID values with LINQ to SQL?
- Update List from another List with Matching values using Linq
- Filter linq query results using values from a list
- Comparing a list of CSV values in Linq to match those from second list with any value in first list
- Select values from multiple dictionaries into list of objects with LINQ
- Linq to get values from 2 list with one unique Id
- Replacing values in a list inside a Linq query with values from a dictionary
- How to select grouped greater values from list with LINQ
- Get results for sub query with matching values from a List
- Get values from a nested list with a LINQ expression
- c# Linq or code to extract groups from a single list of source data
- Using a list of Json results as parameters for a mvc actionresult, to return objects from database with Linq and Lambda
- Combine properties values from a custom List with LINQ
- Create a list from two object lists with linq
- LINQ query to return distinct field values from list of objects
- Limit Number of Results being returned in a List from Linq
- How to select values within a provided index range from a List using LINQ
- Get indexes of all matching values from list using Linq
- Linq to update a collection with values from another collection?
- Select distinct values from a list using LINQ in C#
- How can I set properties on all items from a linq query with values from another object that is also pulled from a query?
- Select Distinct List of Words from Array with LINQ
- Getting unique values from a list of objects with a List<string> as a property
- LINQ - get total count of values from nested list
- How do I ignore/remove non-number values from linq query results C#
- Assign values from one list to another using LINQ
- How to create a list from filtering 2 lists with linq to object
- how to get values from var-source with linq
- Linq Query to Compare with List of string values
- I am trying create a new list of users from a list of users who have not created an additional object with a certain property using LINQ
- Breaking LINQ to Entities into multiple parts
- LINQ Where and FirstOrDefault
- Word count by LINQ
- "..cannot be inferred from the usage." How can I insert both a where and an orderby expression into this sqlite query?
- C# - Add values from list in a fluent interface
- Stored Procedure returning an int
- C# Linq GroupBy - With Specific criteria
- How to select hour in priority
- Best Way To Modify A Property Of Elements In A List According To A Grouping
- Issue with EF LINQ query in .NET Core 3
- LINQ to XML binding to asp.Net DropDownList
- How to set an Entity Framework query equal to a string
- joining in Linq
- Entity Framework Core count with expression parameter
- Can I use Action<T> to perform a recursive search and return an IEnumerable of a specified property?
- C# Return match found with Contains
- Order by child property in list
- Distinct in Entity framework
- Sum of TimeSpan in Entity Framework Core
- Find Items in List<T> based on id