加入IEnumerable <acomplextype> </acomplextype>

时间:2013-11-18 23:54:13

标签: asp.net-mvc entity-framework entity-framework-5

我在数据服务层中有以下方法。我得到“无法创建类型'appModel.dtoFSR'的常量值。在此上下文中只支持基本类型或枚举类型”异常。最后一个参数assignedFSR是另一个服务器中另一个应用程序域中另一个应用程序的查询结果。因此,在我的实体框架上下文中不存在assignedFSR中引用的实体。我无权访问该数据库以将这些实体添加到我的EF上下文中。为了保持Separation of Concern原则,我不想将返回assignedFSR的业务逻辑代码复制到我的项目中。有谁知道如何克服这个短暂的来临?

public IPagedList<dtoTask> GetTasks(int pageSize, int pageIndex, bool completed, int? userId, IEnumerable<dtoFSR> assignedFSR)
{
    var tasks = (from t in AppContext.patient_encounter

                 from p in AppContext.patients
                 .Where(x => t.Patient_ID == x.Patient_ID) /* inner join */

                 from u in AppContext.user
                 .Where(x => t.CreatedBy == x.user_ID) /*inner join */

                 from tt in AppContext.encounter_type
                 .Where(x => t.encounter_type.Value == x.encounter_type1).DefaultIfEmpty() /* left outer join */

                 from tr in AppContext.t_encounter_reason
                 .Where(x => t.Reason.Value == x.reasonID).DefaultIfEmpty() /* left outer join */

                 from d in AppContext.doctors
                 .Where(x => p.PCP.Value == x.doctor_ID).DefaultIfEmpty() /* left outer join */

                  from fsr in assignedFSR
            .Where(x => t.ByWhom == x.FacilityServiceRole_ID).DefaultIfEmpty() /*left outer join*/

                 select new dtoTask
                 {
                     Task = t
                     , Patient = p
                     , CreatedBy = u
                     , TaskType = tt
                     , TaskReason = tr
                     , PCP = d
                     , FSR = fsr /* complex type of dtoFSR*/
                 });

    if (completed)
    {
        tasks = tasks.Where(x => x.Task.deleted.Value.Equals(0) && x.Task.Outcome == "Completed")
                .OrderBy(x => x.Task.Scheduled_Date);
    }
    else
    {
        tasks = tasks.Where(x => x.Task.deleted.Value.Equals(0) && x.Task.Outcome.Length == 0)
                .OrderBy(x => x.Task.Scheduled_Date);
    }

    if (userId.HasValue)
        tasks = tasks.Where(x => x.Task.CreatedBy.Equals(userId.Value));

    IPagedList<dtoTask> pagedList = tasks.ToPagedList(pageIndex + 1, pageSize);

    return pagedList;
}

0 个答案:

没有答案