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 { 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)); } } }