LibraryDAL.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 EMIS.ViewModel.TeachingMaterial;
  8. using System.Linq.Expressions;
  9. namespace EMIS.DataLogic.Common.TeachingMaterial
  10. {
  11. public class LibraryDAL
  12. {
  13. public LibraryRepository LibraryRepository { get; set; }
  14. public UserRepository UserRepository { get; set; }
  15. public CampusRepository CampusRepository { get; set; }
  16. /// <summary>
  17. /// 获取出版单位信息列表
  18. /// </summary>
  19. /// <param name="exp"></param>
  20. /// <returns></returns>
  21. public IQueryable<LibraryView> GetLibraryGridView(Expression<Func<CF_Library, bool>> exp)
  22. {
  23. var view = (from l in LibraryRepository.Entities.Where(exp)
  24. join c in CampusRepository.Entities on l.CampusID equals c.CampusID
  25. join u in UserRepository.Entities on l.CreateUserID equals u.UserID
  26. select new LibraryView
  27. {
  28. LibraryID = l.LibraryID,
  29. LibraryCode = l.LibraryCode,
  30. LibraryName = l.LibraryName,
  31. HeadPeople =l.HeadPeople,
  32. ContectTelNumber = l.ContectTelNumber,
  33. Desc = l.Desc,
  34. CampusCode = c.No,
  35. CampusName = c.Name,
  36. CampusID = l.CampusID,
  37. CreateTime = l.CreateTime,
  38. CreateUserName = u.Name
  39. });
  40. return view;
  41. }
  42. /// <summary>
  43. /// 获取出版单位单位
  44. /// </summary>
  45. /// <returns></returns>
  46. public LibraryView GetSingleLibrary(Guid libraryID)
  47. {
  48. var library = LibraryRepository.GetSingle(x => x.LibraryID == libraryID,
  49. (x => x.CF_Campus));
  50. var publishView = new LibraryView()
  51. {
  52. LibraryID = library.LibraryID,
  53. LibraryName = library.LibraryName,
  54. LibraryCode = library.LibraryCode,
  55. ContectTelNumber = library.ContectTelNumber,
  56. Desc = library.Desc,
  57. HeadPeople = library.HeadPeople,
  58. CampusID = library.CampusID,
  59. CampusCode = library.CF_Campus.No,
  60. CampusName = library.CF_Campus.Name
  61. };
  62. return publishView;
  63. }
  64. }
  65. }