MenuDAL.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.Entities;
  7. using System.Linq.Expressions;
  8. namespace EMIS.DataLogic.SystemDAL
  9. {
  10. public class MenuDAL
  11. {
  12. public RoleRepository RoleRepository { get; set; }
  13. public UserRepository UserRepository { get; set; }
  14. public MenuRepository MenuRepository { get; set; }
  15. public IQueryable<Sys_Menu> GetMenuByUser(
  16. Expression<Func<Sys_Menu, bool>> menuDefineExp,
  17. Expression<Func<Sys_User, bool>> userExp)
  18. {
  19. var userFunc = userExp;
  20. var menuDefineFunc = menuDefineExp;
  21. var iqResult = from m in (
  22. (from u in this.UserRepository.GetList(userExp)
  23. from r in u.Sys_Role
  24. from f in r.Sys_FunctionCode
  25. join m in MenuRepository.GetList(menuDefineExp) on f.FunctionCode equals m.FunctionCode
  26. select m
  27. ).Concat(
  28. MenuRepository.GetList(menuDefineExp).Where(x => x.FunctionCode == null)
  29. )
  30. )
  31. group m by m into g
  32. select g.Key;
  33. return iqResult;
  34. }
  35. }
  36. }