using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using EMIS.Entities;
using EMIS.ViewModel;
using EMIS.ViewModel.StudentManage.OnlineChecking;
using EMIS.ViewModel.SystemView;
using EMIS.DataLogic.Repositories;
namespace EMIS.DataLogic.StudentManage.OnlineChecking
{
public class OpenObjectDAL
{
public StudentEditObjectsRepository StudentEditObjectsRepository { get; set; }
public DictionaryItemRepository DictionaryItemRepository { get; set; }
public DictionaryRepository DictionaryRepository { get; set; }
public UserRepository UserRepository { get; set; }
///
/// 查询学生校对控制开放对象信息OpenObjectView
///
///
///
public IQueryable GetStudentEditObjectQueryable(Expression> exp)
{
var query = from stuobj in StudentEditObjectsRepository.GetList(exp)
join usc in UserRepository.Entities
on stuobj.CreateUserID equals usc.UserID into tempusc
from uscu in tempusc.DefaultIfEmpty()
join usm in UserRepository.Entities
on stuobj.ModifyUserID equals usm.UserID into tempusm
from usmu in tempusm.DefaultIfEmpty()
select new OpenObjectView
{
StudentEditObjectsID = stuobj.StudentEditObjectsID,
EducationID = stuobj.EducationID,
SchoolyearNumID = stuobj.SchoolyearNumID,
Starttime = stuobj.Starttime,
Endtime = stuobj.Endtime,
Remark = stuobj.Remark,
RecordStatus = stuobj.RecordStatus,
CreateUserID = stuobj.CreateUserID,
CreateUserName = uscu.Name,
CreateTime = stuobj.CreateTime,
ModifyUserID = stuobj.ModifyUserID,
ModifyUserName = usmu.Name,
ModifyTime = stuobj.ModifyTime
};
return query;
}
///
/// 查询开放对象中未新增的开放学年信息DictionaryItemView
///
///
///
public IQueryable GetSchoolyearNumNoAddQueryable(Expression> expStudentEditObject)
{
var query = from dicitsyn in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_SchoolyearNum.ToString())
join stuobj in StudentEditObjectsRepository.GetList(expStudentEditObject)
on dicitsyn.Value equals stuobj.SchoolyearNumID into tempobj
from dicitobj in tempobj.DefaultIfEmpty()
join dicsyn in DictionaryRepository.Entities
on dicitsyn.DictionaryCode equals dicsyn.DictionaryCode
where dicitobj.StudentEditObjectsID == null
select new DictionaryItemView
{
DictionaryItemID = dicitsyn.DictionaryItemID,
DictionaryCode = dicitsyn.DictionaryCode,
DictionaryName = dicsyn.Name,
OrderNo = dicitsyn.OrderNo,
Code = dicitsyn.Code,
Name = dicitsyn.Name,
Value = dicitsyn.Value,
IsEditable = dicitsyn.IsEditable == true ? true : false,
IsVisible = dicitsyn.RecordStatus > (int)SYS_STATUS.UNUSABLE ? true : false,
RecordStatus = dicitsyn.RecordStatus
};
return query;
}
}
}