List <T> IXapPoco.SelectList <T>(T obj) { try { List <T> lst = new List <T>(); pocoMap = PocoMapService.Instance.GetPocoMap(obj); if (string.IsNullOrWhiteSpace(_dbConnectionContext.TSql)) { _dbConnectionContext.TSql = pocoMap.SelectListProcedure; } _dataProvider = DbFactory.Instance.Db(_dbConnectionContext); DoInsertUpdate(obj, PocoOperationType.SelectList); XapDataReader dr = _dataProvider.ExecuteReader(); while (dr.Read()) { T newObj = Activator.CreateInstance <T>(); SetListPropertiesFromDataReader <T>(newObj, dr); lst.Add(newObj); } return(lst); } catch (Exception ex) { throw new XapException($"Error performing select list for {typeof(T).FullName}", ex); } finally { _dataProvider.CloseConnection(); } }
IXapEvaluationService IXapValidationProvider.LoadRules <T>(T obj, string ruleType) { IXapDataProvider db = null; IXapRuleSet ruleSet = null; IXapRule rule = null; try { string dbEnvironment = string.Empty; string lobName = string.Empty; string componentName = string.Empty; string ruleDependents = string.Empty; GetDbContext <T>(obj, out dbEnvironment, out lobName, out componentName); db = DbFactory.Instance.Db(dbEnvironment, lobName, "CORE.SelectRules"); XapDataReader dr = db.AddParameter(DbFactory.Instance.DbParameter("RuleType", ruleType)) .AddParameter(DbFactory.Instance.DbParameter("LobName", lobName)) .AddParameter(DbFactory.Instance.DbParameter("ComponentName", componentName)) .AddParameter(DbFactory.Instance.DbParameter("NameSpace", obj.GetType().FullName)) .ExecuteReader(); while (dr.Read()) { ruleSet = evaluationService.GetRuleSet(dr.GetString("RuleSet")); evaluationService.AddRuleSet(ruleSet); rule = ruleSet.GetRule(dr.GetString("RuleName")); rule.RuleType = dr.GetString("RuleType"); rule.RuleSyntax = dr.GetString("RuleSyntax"); rule.RuleDescription = dr.GetString("RuleDesc"); rule.RuleMessage = dr.GetString("RuleMessage"); IXapRuleVariable ruleVariable = EvaluationFactory.Instance.CreateRuleVariable(dr.GetString("PropertyName")); rule.AddRuleVariable(ruleVariable); ruleDependents = dr.GetString("Dependencies"); string[] dependents = ruleDependents.Split(','); for (int i = 0; i < dependents.Length; i++) { IXapRuleVariable variableDependent = EvaluationFactory.Instance.CreateRuleVariable(dependents[i]); rule.AddRuleVariable(variableDependent); } ruleSet.AddRule(rule); } return(evaluationService); }catch (XapException ex) { throw; }catch (Exception ex) { throw new XapException($"Error loading validation rules for {obj.GetType().FullName}", ex); } finally { db.CloseConnection(); } }
T IXapPoco.Select <T>(T obj) { try { pocoMap = PocoMapService.Instance.GetPocoMap(obj); if (string.IsNullOrWhiteSpace(_dbConnectionContext.TSql)) { _dbConnectionContext.TSql = pocoMap.SelectProcedure; } _dataProvider = DbFactory.Instance.Db(_dbConnectionContext); DoInsertUpdate(obj, PocoOperationType.Select); XapDataReader dr = _dataProvider.ExecuteReader(); SetPropertiesFromDataReader <T>(obj, dr); return(obj); } catch (Exception ex) { throw new XapException($"Error performing select for {typeof(T).FullName}", ex); } finally { _dataProvider.CloseConnection(); } }