12345678910111213141516171819202122232425262728293031323334353637 |
-
- using DbCommon.BusinessCore.DbCore;
- using DbCommon.Enties.DbModels;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DbCommon.BusinessCore.BaseCore
- {
- public class MaterialBindingManager : DbContext<MaterialBinding>
- {
- public void Init()
- {
- //If no exist create datebase
- //Db.DbMaintenance.CreateDatabase();
- //var dt = Db.Ado.GetDataTable("SELECT * FROM sysobjects WHERE NAME = 'MaterialBinding'");
- if (!Db.DbMaintenance.IsAnyTable("MaterialBinding", false))
- {
- //Create tables
- Db.CodeFirst.InitTables(typeof(MaterialBinding));
- }
- }
- public bool Save(MaterialBinding data)
- {
- return Db.Saveable(data).ExecuteCommand() > 0;
- }
- public bool DeleteOldData(int day = 90)
- {
- return CurrentDb.Delete(d => d.CreateTime < DateTime.Now.AddDays(day * -1));
- }
- }
- }
|