MenuDAL.cs 1.6 KB

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