Linq to SQL DTOs and composite objects

后端 未结 3 1100
栀梦
栀梦 2021-02-10 16:29

I am using a similar approach to others in keeping my LINQ objects in my LINQ data provider and returning an IQueryable to allow filtering etc. This works fine for filtering a

3条回答
  •  我在风中等你
    2021-02-10 17:12

    I have been able to work successfully with a similar approach:

    var courses = from c in Map(origCourses)
    where !expiredStatuses.Contains(c.Status)
    select c;
    

    Where Map has:

        select new UserCourseListItem
        {
            CourseID = c.CourseID,
            CourseName = cm.CourseName,
            CourseType = c.CourseType.Value
            ...
    

    How about trying it with that type of initialization (instead of constructors).

    Ps. this is part of a working application, and the expiredStatuses is even related to a complex expression.

    Update 1: This is similar compared to the mentioned scenario, because:

    • Map is returning an IQueryable, which is a POCO object.
    • After calling the Map method that returns an IQueryable with the POCO object I am applying a filter against it.

提交回复
热议问题