protected void SaveDetailEntities(List <DetailObjectInfo> detailList) { if (detailList == null) { return; } foreach (var detailInfo in detailList) { IDataAccessBase da = EntityFactory.GetEntityDataAccessByName(detailInfo.EntityName, detailInfo.AdditionalDataKey); da.AutoSave = false; if (detailInfo.FnName == RuleFunctionSEnum.Insert) { da.Insert(detailInfo.EntitySet, new InsertParameters()); } else if (detailInfo.FnName == RuleFunctionSEnum.Update) { da.Update(detailInfo.EntitySet, new UpdateParameters()); } else if (detailInfo.FnName == RuleFunctionSEnum.Delete) { da.Delete(detailInfo.EntitySet, new DeleteParameters()); } else { throw new Exception("Function " + detailInfo.FnName + " is not defined in DataAccessLayer"); } } }
public CDataAccessBase[] getObjList(IDataAccessBase obj, int RecordCount) { CClassQuery ccq = obj.generateListSql(RecordCount); if (ccq == null) { return(null); } Type t = obj.GetType(); DataTable dt = this.ExecQuery(ccq.sql, ccq.parameters); CDataAccessBase[] ba = null; if (dt.Rows.Count > 0) { ba = new CDataAccessBase[dt.Rows.Count]; } int i = 0; foreach (DataRow dr in dt.Rows) { CDataAccessBase k = (CDataAccessBase)Activator.CreateInstance(t); k.InitFromDataRow(dr); ba[i] = k; i++; } return(ba); }
public CDataAccessBase[] getObjList(IDataAccessBase obj, int PageIndex, int PageSize) { Type t = obj.GetType(); DataTable dt = ExecProcedure("AllowPaging", new[] { new OleDbParameter("@pageindex", PageIndex), new OleDbParameter("@PageSize", PageSize), new OleDbParameter("@tsql", obj.generateListSql()) } ).Tables[0]; CDataAccessBase[] ba = null; if (dt.Rows.Count > 0) { ba = new CDataAccessBase[dt.Rows.Count]; } int i = 0; foreach (DataRow dr in dt.Rows) { var k = (CDataAccessBase)Activator.CreateInstance(t); k.InitFromDataRow(dr); ba[i] = k; i++; } return(ba); }
/// <summary> /// Gets the name of the entity data access by. /// </summary> /// <param name="entityName">Name of the entity.</param> /// <param name="additionalDataKey">The additional data key.</param> /// <returns></returns> public IDataAccessBase GetEntityDataAccessByName(string entityName, string additionalDataKey) { ApplicationSetting appSetting = FWUtils.ConfigUtils.GetAppSettings(); IDataAccessBase obj = (IDataAccessBase)FWUtils.ReflectionUtils.CreateInstance(appSetting.Project.NamespacePrefix + ".DataAccess", entityName + "DA", appSetting.Project.NamespacePrefix + ".DataAccess", new object[] { additionalDataKey }); obj.Initialize(entityName, additionalDataKey); return(obj); }
/// <summary> /// 判断对象是否在数据库中存在 /// </summary> /// <param name="obj">对象</param> /// <returns></returns> public bool CheckObj(IDataAccessBase obj) { CClassQuery ccq = obj.CheckObj(); if (ccq == null) { return(false); } return(HasRecord(ccq.sql, ccq.parameters)); }
public void GetEntityDataAccessByNameTest() { ProjectEntityFactory target = new ProjectEntityFactory(); string entityName = vTestCaseTester.EntityName; string additionalDataKey = ""; IDataAccessBase expected = null; IDataAccessBase actual; actual = target.GetEntityDataAccessByName(entityName, additionalDataKey); Assert.AreNotEqual(expected, actual); }
public CDataAccessBase getObj(IDataAccessBase obj) { CClassQuery ccq = obj.CheckObj(); if (ccq == null) { return(null); } Type t = obj.GetType(); DataTable dt = this.ExecQuery(ccq.sql, ccq.parameters); CDataAccessBase ba = null; int i = 0; foreach (DataRow dr in dt.Rows) { CDataAccessBase k = (CDataAccessBase)Activator.CreateInstance(t); k.InitFromDataRow(dr); ba = k; break; } return(ba); }
public ServiceBase(IDataAccessBase <T> dataAccessBase) { _dataAccessBase = dataAccessBase; }
public MenuDataAccess(IDataAccessBase <MenuModel> dataAccessBase) { _dbContext = dataAccessBase; Console.Out.WriteLine($"{nameof(MenuDataAccess)}对象被构建"); }
public UserDataAccess(IDataAccessBase <UserModel> dataAccessBase) { _dbContext = dataAccessBase; Console.Out.WriteLine($"{nameof(UserDataAccess)}对象被构建"); }
public PermissionsDataAccess(IDataAccessBase <PermissionsModel> dataAccessBase) { _dbContext = dataAccessBase; }