score:3
Accepted answer
Why not put that query inside a generic method?
MyBase Get<T>(IEnumerable<T> list) where T : MyBase
{
MyBase testItem = from x in list
from y in x.SolidItems
where y.Classified == otherObject.Classified
select x;
return testItem;
}
You could call it like this:
var result1 = Get(AbcTransport);
var result2 = Get(DefTransport);
Source: stackoverflow.com
Related Articles
- Dynamic LINQ (to objects): Substituting a object name in a query from a list of object names (string)?
- Return a specific object in a LINQ select query from two different objects in a list
- LINQ query to return distinct field values from list of objects
- Linq select object from list depending on objects attribute
- Linq query a List of objects containing a list of object
- Query in returning Objects from List using LINQ
- LINQ query using list of objects property of an object
- Build dynamic linq select query from existing list
- Linq query to get an object from list of lists
- Query with LINQ where Context matches multiple parameters from a List of Objects
- What is the correct way of retrieving a given business object from a list of business objects using LINQ Where vs. Find?
- Returning an object from a LINQ query without casting it to a list
- Linq query to get the properties from object B which have the same name and type of object A
- How to use LINQ to query from a list of objects into an existing object?
- Linq query for updating list of objects with some data from another list of objects
- Efficient linq query to return objects when you have a list of object id's
- Using LINQ to isolate a particular object from a list of objects
- Linq code to get the index of an object in an array from an object within a list
- Generate a list of custom objects from Json object using LINQ
- Using a Linq query to select objects where any value of a property matches values from a list
- Get list of list of objects from linq query
- LINQ query to create a list of objects where each object contains a list
- Linq Query to get List of Objects and for Each of Object get another nested List
- How to use LINQ to get an object from List of objects matching option from List of options
- Dynamic Linq Expression Query Nested List Object
- c# Linq or code to extract groups from a single list of source data
- Dynamic linq query that Contains ALL from another list
- Get Class and object type from linq list query
- linq query on multiple columns from a list of objects
- How to return an object (or a list of objects) of anonymous type from a LINQ query to the UI (Console App) in C#?
- LINQ query syntax for selectmany + join + let
- c# linq group by - Access other properties inside select new
- How to setup the definition file to use LINQ in an Azure Function?
- Map Hierarchical Collection of Domain Objects to Hierarchical Collection of ViewModels
- Set operation on a list of strings
- Why is "Divide by Zero" or any other exception not raised?
- Transpose Data in C# Business Objects
- How can I get my information from the 2 tables into 1 row?
- Setting a datatable cell value using LINQ according to some conditions
- C# foreach doesn't modify properties of elements when iterating over collection created by linq .Select()
- Dynamic order by clause in a single LINQ query
- Does Castle ActiveRecord's ActiveRecordMediator<> support LINQ?
- Removing items from an object where linked model has 0 items
- ASP.NET Core SQL Linq using list of strings
- Random Orderby on subquery in LINQ
- Why am I able to edit a LINQ list while iterating over it?
- How to get compile-time checking for value types in LINQ/lambdas/expression trees?
- MVC: Repopulate filters form's fields without using Model
- Linq group by with sub grouping
- The most simple LINQ to XML query. But I can't get it