/// <summary> /// 关系映射 /// </summary> /// <param name="type">实体类Type</param> public ContextMap(Type type) { Type = type; MapList = new Dictionary<PropertyInfo, SetState>(); #region 类属性 var attContext = Type.GetCustomAttributes(typeof(ContextAttribute), false); foreach (var attr in attContext.OfType<ContextAttribute>()) { ContextProperty = attr; } if (ContextProperty == null) { ContextProperty = new ContextAttribute(); } #endregion #region 变量属性 // 遍历所有Set属性(表、视图、存储过程的名称),取得对应使用标记名称 foreach (var setProperty in Type.GetProperties()) { if (!new List<string> { "ViewSet`1", "ViewSetCache`1", "TableSet`1", "TableSetCache`1", "ProcSet`1" }.Contains(setProperty.PropertyType.Name)) { continue; } var setState = new SetState(); #region Set属性 var setAtt = setProperty.GetCustomAttributes(typeof(SetAttribute), false); foreach (var attr in setAtt.OfType<SetAttribute>()) { setState.SetAtt = attr; } if (setState.SetAtt == null) { setState.SetAtt = new SetAttribute(); } if (string.IsNullOrWhiteSpace(setState.SetAtt.Name)) { setState.SetAtt.Name = setProperty.Name; } #endregion // 映射Set属性 setState.FieldMap = CacheManger.GetFieldMap(setProperty.PropertyType.GetGenericArguments()[0]); //添加属变量标记名称 MapList.Add(setProperty, setState); } #endregion }
/// <summary> /// 关系映射 /// </summary> /// <param name="type">实体类Type</param> public ContextMap(Type type) { Type = type; MapList = new Dictionary<PropertyInfo, SetState>(); #region 变量属性 // 遍历所有Set属性(表、视图、存储过程的名称),取得对应使用标记名称 foreach (var setProperty in Type.GetProperties()) { if (!new List<string> { "ViewSet`1", "ViewSetCache`1", "TableSet`1", "TableSetCache`1", "ProcSet`1" }.Contains(setProperty.PropertyType.Name)) { continue; } var setState = new SetState(); #region Set属性 var setAtt = setProperty.GetCustomAttributes(typeof(SetAttribute), false); setState.SetAtt = setAtt.Length > 0 ? (SetAttribute)setAtt[0] : new SetAttribute(); if (string.IsNullOrWhiteSpace(setState.SetAtt.Name)) { setState.SetAtt.Name = setProperty.Name; } #endregion #region 软删除标记属性 var sortDeleteAtt = setProperty.GetCustomAttributes(typeof(SortDeleteAttribute), false); if (sortDeleteAtt.Length > 0) { setState.SortDeleteAtt = (SortDeleteAttribute)sortDeleteAtt[0]; setState.SortDeleteAtt.Init(setProperty.PropertyType.GetGenericArguments()[0]); } #endregion // 映射字段属性 setState.FieldMap = CacheManger.GetFieldMap(setProperty.PropertyType.GetGenericArguments()[0]); //添加属变量标记名称 MapList.Add(setProperty, setState); } #endregion }
internal Queue(int index, string name, IContextProvider provider, SetState map) { ID = Guid.NewGuid(); Index = index; Name = name; ContextProvider = provider; _map = map; }
internal Queue(int index, string name, IContextProvider provider, SetState map) { ID = Guid.NewGuid(); Index = index; Name = name; ContextProvider = provider; ExpBuilder = new ExpressionBuilder(map); SqlBuilder = provider.DbProvider.CreateSqlBuilder(provider.Map.ContextProperty.DataVer, ExpBuilder, Name); }
/// <summary> /// 关系映射 /// </summary> /// <param name="type">实体类Type</param> public ContextMap(Type type) { Type = type; MapList = new Dictionary <PropertyInfo, SetState>(); #region 类属性 var attContext = Type.GetCustomAttributes(typeof(ContextAttribute), false); foreach (var attr in attContext.OfType <ContextAttribute>()) { ContextProperty = attr; } if (ContextProperty == null) { ContextProperty = new ContextAttribute(); } #endregion #region 变量属性 // 遍历所有Set属性(表、视图、存储过程的名称),取得对应使用标记名称 foreach (var setProperty in Type.GetProperties()) { if (!new List <string> { "ViewSet`1", "ViewSetCache`1", "TableSet`1", "TableSetCache`1", "ProcSet`1" }.Contains(setProperty.PropertyType.Name)) { continue; } var setState = new SetState(); #region Set属性 var setAtt = setProperty.GetCustomAttributes(typeof(SetAttribute), false); foreach (var attr in setAtt.OfType <SetAttribute>()) { setState.SetAtt = attr; } if (setState.SetAtt == null) { setState.SetAtt = new SetAttribute(); } if (string.IsNullOrWhiteSpace(setState.SetAtt.Name)) { setState.SetAtt.Name = setProperty.Name; } #endregion // 映射Set属性 setState.FieldMap = CacheManger.GetFieldMap(setProperty.PropertyType.GetGenericArguments()[0]); //添加属变量标记名称 MapList.Add(setProperty, setState); } #endregion }