123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.ScoreManage;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.ViewModel;
- namespace EMIS.DataLogic.ScoreManage
- {
- public class ScoreParameterSettingDAL
- {
- public ScoreParameterSettingRepository ScoreParameterSettingRepository { get; set; }
- public DictionaryItemRepository DictionaryItemRepository { get; set; }
- public IQueryable<ER_ScoreParameterSetting> GetScoreParameterSettingViewQueryable(Expression<Func<ER_ScoreParameterSetting, bool>> exp)
- {
- var query = from a in ScoreParameterSettingRepository.GetList(exp)
- select a;
- return query;
- }
- public IQueryable<ScoreParameterSettingView> GetScoreParameterSettingViewQueryable()
- {
- var sql = (from detail in ScoreParameterSettingRepository.Entities
- where detail.ExamsTypeID == null && detail.CourseTypeID == null
- select new ScoreParameterSettingView
- {
- ExamsTypeID = null,
- ExamsTypeName = null,
- CourseTypeID = null,
- CourseTypeName = null,
- ScoreFormulaID = detail.ScoreFormulaID,
- IsTotalFormula = detail.IsTotalFormula ?? false,
- CreditFormulaID = detail.CreditFormulaID,
- IsCreditFormula = detail.IsCreditFormula ?? false,
- GradePointFormulaID = detail.GradePointFormulaID,
- IsGradePointFormula = detail.IsGradePointFormula ?? false,
- OrderNo = (detail.ExamsTypeID ?? 0) * (detail.CourseTypeID ?? 0)
- }).Concat(
- from category in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_ExamsCategory.ToString())
- join detail in ScoreParameterSettingRepository.Entities
- on new { ExamsTypeID = category.Value, CourseTypeID = (int?)null }
- equals new { detail.ExamsTypeID, detail.CourseTypeID } into ddetail
- from detail in ddetail.DefaultIfEmpty()
- select new ScoreParameterSettingView
- {
- ExamsTypeID = category.Value,
- ExamsTypeName = category.Name,
- CourseTypeID = null,
- CourseTypeName = null,
- ScoreFormulaID = detail.ScoreFormulaID,
- IsTotalFormula = detail.IsTotalFormula ?? false,
- CreditFormulaID = detail.CreditFormulaID,
- IsCreditFormula = detail.IsCreditFormula ?? false,
- GradePointFormulaID = detail.GradePointFormulaID,
- IsGradePointFormula = detail.IsGradePointFormula ?? false,
- OrderNo = (detail.ExamsTypeID ?? 0) * (detail.CourseTypeID ?? 0)
- }
- ).Concat(
- from courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_CourseType.ToString())
- join detail in ScoreParameterSettingRepository.Entities
- on new { ExamsTypeID = (int?)null, CourseTypeID = courseType.Value }
- equals new { detail.ExamsTypeID, detail.CourseTypeID } into ddetail
- from detail in ddetail.DefaultIfEmpty()
- select new ScoreParameterSettingView
- {
- ExamsTypeID = null,
- ExamsTypeName = null,
- CourseTypeID = courseType.Value,
- CourseTypeName = courseType.Name,
- ScoreFormulaID = detail.ScoreFormulaID,
- IsTotalFormula = detail.IsTotalFormula ?? false,
- CreditFormulaID = detail.CreditFormulaID,
- IsCreditFormula = detail.IsCreditFormula ?? false,
- GradePointFormulaID = detail.GradePointFormulaID,
- IsGradePointFormula = detail.IsGradePointFormula ?? false,
- OrderNo = (detail.ExamsTypeID ?? 0) * (detail.CourseTypeID ?? 0)
- }
- ).Concat(
- from category in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_ExamsCategory.ToString())
- join courseType in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_CourseType.ToString())
- on true equals true
- join detail in ScoreParameterSettingRepository.Entities
- on new { ExamsTypeID = category.Value, CourseTypeID = courseType.Value }
- equals new { detail.ExamsTypeID, detail.CourseTypeID } into ddetail
- from detail in ddetail.DefaultIfEmpty()
- select new ScoreParameterSettingView
- {
- ExamsTypeID = category.Value,
- ExamsTypeName = category.Name,
- CourseTypeID = courseType.Value,
- CourseTypeName = courseType.Name,
- ScoreFormulaID = detail.ScoreFormulaID,
- IsTotalFormula = detail.IsTotalFormula ?? false,
- CreditFormulaID = detail.CreditFormulaID,
- IsCreditFormula = detail.IsCreditFormula ?? false,
- GradePointFormulaID = detail.GradePointFormulaID,
- IsGradePointFormula = detail.IsGradePointFormula ?? false,
- OrderNo = (detail.ExamsTypeID ?? 0) * (detail.CourseTypeID ?? 0)
- });
- return sql;
- }
- }
- }
|