A list is an ICollection. You can change the query.ToList () code as follows.
query.ToList() as ICollection<SoilSamplingSubJob>;
You ask how this query is returned as a result of a function. If so, remember that Linq to SQL objects are connected by default, so you will need to control where your database context opens and closes. In addition, you can create DTOs (data transfer objects) that contain the data that you want to use in the rest of your program. These objects can fit into your object hierarchy in any way.
You can also create these DTOs as part of the request.
var query = from m in db.SoilSamplingSubJobs where m.order_id == id select new SubJobDTO { OrderNumber = m.order_id }; return query.ToList() as ICollection<SubJobDTO>;
Jason
source share