MaterialBindingManager.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. 
  2. using DbCommon.BusinessCore.DbCore;
  3. using DbCommon.Enties.DbModels;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace DbCommon.BusinessCore.BaseCore
  10. {
  11. public class MaterialBindingManager : DbContext<MaterialBinding>
  12. {
  13. public void Init()
  14. {
  15. //If no exist create datebase
  16. //Db.DbMaintenance.CreateDatabase();
  17. //var dt = Db.Ado.GetDataTable("SELECT * FROM sysobjects WHERE NAME = 'MaterialBinding'");
  18. if (!Db.DbMaintenance.IsAnyTable("MaterialBinding", false))
  19. {
  20. //Create tables
  21. Db.CodeFirst.InitTables(typeof(MaterialBinding));
  22. }
  23. }
  24. public bool Save(MaterialBinding data)
  25. {
  26. return Db.Saveable(data).ExecuteCommand() > 0;
  27. }
  28. public bool DeleteOldData(int day = 90)
  29. {
  30. return CurrentDb.Delete(d => d.CreateTime < DateTime.Now.AddDays(day * -1));
  31. }
  32. }
  33. }