mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	ICodeFirst add GetConfigEntity
This commit is contained in:
		@@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  <PropertyGroup>
 | 
					  <PropertyGroup>
 | 
				
			||||||
    <TargetFramework>netstandard2.0</TargetFramework>
 | 
					    <TargetFramework>netstandard2.0</TargetFramework>
 | 
				
			||||||
    <Version>0.1.1</Version>
 | 
					    <Version>0.1.2</Version>
 | 
				
			||||||
    <Authors>YeXiangQin</Authors>
 | 
					    <Authors>YeXiangQin</Authors>
 | 
				
			||||||
    <Description>打造 .NETCore 最方便的 ORM,DbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>
 | 
					    <Description>打造 .NETCore 最方便的 ORM,DbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>
 | 
				
			||||||
    <PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
 | 
					    <PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  <PropertyGroup>
 | 
					  <PropertyGroup>
 | 
				
			||||||
    <TargetFramework>netstandard2.0</TargetFramework>
 | 
					    <TargetFramework>netstandard2.0</TargetFramework>
 | 
				
			||||||
    <Version>0.1.1</Version>
 | 
					    <Version>0.1.2</Version>
 | 
				
			||||||
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
 | 
					    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
 | 
				
			||||||
    <Authors>YeXiangQin</Authors>
 | 
					    <Authors>YeXiangQin</Authors>
 | 
				
			||||||
    <Description>打造 .NETCore 最方便的 ORM,DbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>
 | 
					    <Description>打造 .NETCore 最方便的 ORM,DbFirst 与 CodeFirst 混合使用,提供从实体同步数据库,或者从数据库生成实体代码,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite 数据库。</Description>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,7 +53,25 @@ namespace FreeSql {
 | 
				
			|||||||
		/// <param name="type"></param>
 | 
							/// <param name="type"></param>
 | 
				
			||||||
		/// <returns></returns>
 | 
							/// <returns></returns>
 | 
				
			||||||
		(int type, string dbtype, string dbtypeFull, bool? isnullable, object defaultValue)? GetDbInfo(Type type);
 | 
							(int type, string dbtype, string dbtypeFull, bool? isnullable, object defaultValue)? GetDbInfo(Type type);
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// 在外部配置实体的特性
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
 | 
							/// <typeparam name="T"></typeparam>
 | 
				
			||||||
 | 
							/// <param name="entity"></param>
 | 
				
			||||||
 | 
							/// <returns></returns>
 | 
				
			||||||
		ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity);
 | 
							ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity);
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// 在外部配置实体的特性
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
 | 
							/// <param name="type"></param>
 | 
				
			||||||
 | 
							/// <param name="entity"></param>
 | 
				
			||||||
 | 
							/// <returns></returns>
 | 
				
			||||||
		ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity);
 | 
							ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity);
 | 
				
			||||||
 | 
							/// <summary>
 | 
				
			||||||
 | 
							/// 获取在外部配置实体的特性
 | 
				
			||||||
 | 
							/// </summary>
 | 
				
			||||||
 | 
							/// <param name="type"></param>
 | 
				
			||||||
 | 
							/// <returns>未使用ConfigEntity配置时,返回null</returns>
 | 
				
			||||||
 | 
							TableAttribute GetConfigEntity(Type type);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,6 +50,9 @@ namespace FreeSql.Internal {
 | 
				
			|||||||
			Utils.GetTableByEntity(type, this, true); //update cache
 | 
								Utils.GetTableByEntity(type, this, true); //update cache
 | 
				
			||||||
			return _orm.CodeFirst;
 | 
								return _orm.CodeFirst;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							internal TableAttribute GetConfigEntity(Type type) {
 | 
				
			||||||
 | 
								return dicConfigEntity.TryGetValue(type, out var trytb) ? trytb : null;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		internal TableAttribute GetEntityTableAttribute(Type type) {
 | 
							internal TableAttribute GetEntityTableAttribute(Type type) {
 | 
				
			||||||
			var attr = type.GetCustomAttributes(typeof(TableAttribute), false).LastOrDefault() as TableAttribute;
 | 
								var attr = type.GetCustomAttributes(typeof(TableAttribute), false).LastOrDefault() as TableAttribute;
 | 
				
			||||||
			if (dicConfigEntity.TryGetValue(type, out var trytb) == false) return attr;
 | 
								if (dicConfigEntity.TryGetValue(type, out var trytb) == false) return attr;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -274,5 +274,6 @@ where a.table_schema in ({0}) and a.table_name in ({1})".FormatMySql(tboldname ?
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
							public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
				
			||||||
		public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
							public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
				
			||||||
 | 
							public TableAttribute GetConfigEntity(Type type) => _commonUtils.GetConfigEntity(type);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -312,5 +312,6 @@ where owner={{0}} and table_name={{1}}".FormatOracleSQL(tboldname ?? tbname);
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
							public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
				
			||||||
		public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
							public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
				
			||||||
 | 
							public TableAttribute GetConfigEntity(Type type) => _commonUtils.GetConfigEntity(type);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -326,5 +326,6 @@ where pg_namespace.nspname={0} and pg_class.relname={1} and pg_constraint.contyp
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
							public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
				
			||||||
		public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
							public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
				
			||||||
 | 
							public TableAttribute GetConfigEntity(Type type) => _commonUtils.GetConfigEntity(type);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -284,5 +284,6 @@ use " + database, tboldname ?? tbname);
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
							public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
				
			||||||
		public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
							public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
				
			||||||
 | 
							public TableAttribute GetConfigEntity(Type type) => _commonUtils.GetConfigEntity(type);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -242,5 +242,6 @@ namespace FreeSql.Sqlite {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
							public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity) => _commonUtils.ConfigEntity(entity);
 | 
				
			||||||
		public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
							public ICodeFirst ConfigEntity(Type type, Action<TableFluent> entity) => _commonUtils.ConfigEntity(type, entity);
 | 
				
			||||||
 | 
							public TableAttribute GetConfigEntity(Type type) => _commonUtils.GetConfigEntity(type);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user