FunctionDAL.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel.SystemView;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. namespace EMIS.DataLogic.SystemDAL
  10. {
  11. public class FunctionDAL
  12. {
  13. public FunctionCodeRepository FunctionCodeRepository { get; set; }
  14. public RoleRepository RoleRepository { get; set; }
  15. public IQueryable<FunctionCodeView> GetAllFunctionCodeView()
  16. {
  17. var q = (from fc in FunctionCodeRepository.Entities
  18. select new FunctionCodeView
  19. {
  20. FunctionCode = fc.FunctionCode,
  21. FunctionName = fc.FunctionName,
  22. ParentFunctionCode = fc.ParentFunctionCode,
  23. OrderNo = fc.OrderNo
  24. }
  25. ).Distinct();
  26. return q;
  27. }
  28. public IQueryable<FunctionCodeView> GetSelectedFunctionCodeViewByRole(Expression<Func<Sys_Role, bool>> exp)
  29. {
  30. var q = (from r in RoleRepository.GetList(exp)
  31. from fc in r.Sys_FunctionCode
  32. select new FunctionCodeView
  33. {
  34. FunctionCode = fc.FunctionCode,
  35. FunctionName = fc.FunctionName,
  36. ParentFunctionCode = fc.ParentFunctionCode,
  37. OrderNo = fc.OrderNo
  38. }
  39. ).Distinct();
  40. return q;
  41. }
  42. }
  43. }