mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
v0.3.12 增加 ICodeFirst.IsConfigEntityFromDbFirst,若无配置实体类主键、自增,可从数据库导入;
This commit is contained in:
parent
4f66c3b9eb
commit
dae8eb7a67
@ -11,12 +11,14 @@ namespace net46_console_01 {
|
|||||||
|
|
||||||
var orm = new FreeSql.FreeSqlBuilder()
|
var orm = new FreeSql.FreeSqlBuilder()
|
||||||
.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document.db;Pooling=true;Max Pool Size=10")
|
.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document.db;Pooling=true;Max Pool Size=10")
|
||||||
|
//.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
|
||||||
.UseAutoSyncStructure(true)
|
.UseAutoSyncStructure(true)
|
||||||
|
.UseConfigEntityFromDbFirst(true)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var repos = orm.GetGuidRepository<Song>();
|
var repos = orm.GetGuidRepository<Song22>();
|
||||||
|
|
||||||
var item = repos.Insert(new Song());
|
var item = repos.Insert(new Song22());
|
||||||
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(item));
|
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(item));
|
||||||
|
|
||||||
item.Title = "xxx";
|
item.Title = "xxx";
|
||||||
@ -31,7 +33,7 @@ namespace net46_console_01 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Song {
|
public class Song22 {
|
||||||
|
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
|
@ -39,12 +39,6 @@
|
|||||||
<Reference Include="CSScriptLib, Version=1.0.6.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="CSScriptLib, Version=1.0.6.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\CS-Script.Core.1.0.6\lib\netstandard2.0\CSScriptLib.dll</HintPath>
|
<HintPath>..\..\packages\CS-Script.Core.1.0.6\lib\netstandard2.0\CSScriptLib.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="FreeSql, Version=0.1.11.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\packages\FreeSql.0.1.11\lib\netstandard2.0\FreeSql.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="FreeSql.Repository, Version=0.1.11.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\packages\FreeSql.Repository.0.1.11\lib\netstandard2.0\FreeSql.Repository.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Google.Protobuf, Version=3.5.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
|
<Reference Include="Google.Protobuf, Version=3.5.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Google.Protobuf.3.5.1\lib\net45\Google.Protobuf.dll</HintPath>
|
<HintPath>..\..\packages\Google.Protobuf.3.5.1\lib\net45\Google.Protobuf.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -269,6 +263,16 @@
|
|||||||
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.2.6.1\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
|
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.2.6.1\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
|
||||||
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.2.6.1\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
|
<Analyzer Include="..\..\packages\Microsoft.CodeAnalysis.Analyzers.2.6.1\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\FreeSql.Repository\FreeSql.Repository.csproj">
|
||||||
|
<Project>{ac47670e-90bb-4502-9965-0739bdf6fe2e}</Project>
|
||||||
|
<Name>FreeSql.Repository</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\FreeSql\FreeSql.csproj">
|
||||||
|
<Project>{af9c50ec-6eb6-494b-9b3b-7edba6fd0ebb}</Project>
|
||||||
|
<Name>FreeSql</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="..\..\packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\..\packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets')" />
|
<Import Project="..\..\packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\..\packages\System.Data.SQLite.Core.1.0.110.0\build\net46\System.Data.SQLite.Core.targets')" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<Version>0.3.11</Version>
|
<Version>0.3.12</Version>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 通用仓库层实现,支持 MySql/SqlServer/PostgreSQL/Oracle/Sqlite,读写分离、分表分库。</Description>
|
<Description>FreeSql 通用仓库层实现,支持 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.3.11</Version>
|
<Version>0.3.12</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>
|
||||||
|
@ -15,6 +15,7 @@ namespace FreeSql {
|
|||||||
bool _isAutoSyncStructure = false;
|
bool _isAutoSyncStructure = false;
|
||||||
bool _isSyncStructureToLower = false;
|
bool _isSyncStructureToLower = false;
|
||||||
bool _isSyncStructureToUpper = false;
|
bool _isSyncStructureToUpper = false;
|
||||||
|
bool _isConfigEntityFromDbFirst = false;
|
||||||
bool _isLazyLoading = false;
|
bool _isLazyLoading = false;
|
||||||
Action<DbCommand> _aopCommandExecuting = null;
|
Action<DbCommand> _aopCommandExecuting = null;
|
||||||
Action<DbCommand, string> _aopCommandExecuted = null;
|
Action<DbCommand, string> _aopCommandExecuted = null;
|
||||||
@ -86,6 +87,15 @@ namespace FreeSql {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 使用数据库的主键和自增,适用 DbFirst 模式,无须在实体类型上设置 [Column(IsPrimary)] 或者 ConfigEntity。此功能目前可用于 mysql/sqlserver/postgresql。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public FreeSqlBuilder UseConfigEntityFromDbFirst(bool value) {
|
||||||
|
_isConfigEntityFromDbFirst = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// 延时加载导航属性对象,导航属性需要声明 virtual
|
/// 延时加载导航属性对象,导航属性需要声明 virtual
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
@ -120,6 +130,7 @@ namespace FreeSql {
|
|||||||
|
|
||||||
ret.CodeFirst.IsSyncStructureToLower = _isSyncStructureToLower;
|
ret.CodeFirst.IsSyncStructureToLower = _isSyncStructureToLower;
|
||||||
ret.CodeFirst.IsSyncStructureToUpper = _isSyncStructureToUpper;
|
ret.CodeFirst.IsSyncStructureToUpper = _isSyncStructureToUpper;
|
||||||
|
ret.CodeFirst.IsConfigEntityFromDbFirst = _isConfigEntityFromDbFirst;
|
||||||
ret.CodeFirst.IsLazyLoading = _isLazyLoading;
|
ret.CodeFirst.IsLazyLoading = _isLazyLoading;
|
||||||
var ado = ret.Ado as Internal.CommonProvider.AdoProvider;
|
var ado = ret.Ado as Internal.CommonProvider.AdoProvider;
|
||||||
ado.AopCommandExecuting += _aopCommandExecuting;
|
ado.AopCommandExecuting += _aopCommandExecuting;
|
||||||
|
@ -18,6 +18,10 @@ namespace FreeSql {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsSyncStructureToUpper { get; set; }
|
bool IsSyncStructureToUpper { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 使用数据库的主键和自增,适用 DbFirst 模式,无须在实体类型上设置 [Column(IsPrimary)] 或者 ConfigEntity。此功能目前可用于 mysql/sqlserver/postgresql。
|
||||||
|
/// </summary>
|
||||||
|
bool IsConfigEntityFromDbFirst { get; set; }
|
||||||
|
/// <summary>
|
||||||
/// 延时加载导航属性对象,导航属性需要声明 virtual
|
/// 延时加载导航属性对象,导航属性需要声明 virtual
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsLazyLoading { get; set; }
|
bool IsLazyLoading { get; set; }
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
|
using FreeSql.DatabaseModel;
|
||||||
using FreeSql.Internal.Model;
|
using FreeSql.Internal.Model;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@ -27,6 +28,8 @@ namespace FreeSql.Internal {
|
|||||||
internal IFreeSql _orm { get; set; }
|
internal IFreeSql _orm { get; set; }
|
||||||
internal ICodeFirst CodeFirst => _orm.CodeFirst;
|
internal ICodeFirst CodeFirst => _orm.CodeFirst;
|
||||||
internal TableInfo GetTableByEntity(Type entity) => Utils.GetTableByEntity(entity, this);
|
internal TableInfo GetTableByEntity(Type entity) => Utils.GetTableByEntity(entity, this);
|
||||||
|
internal List<DbTableInfo> dbTables { get; set; }
|
||||||
|
internal object dbTablesLock = new object();
|
||||||
|
|
||||||
public CommonUtils(IFreeSql orm) {
|
public CommonUtils(IFreeSql orm) {
|
||||||
_orm = orm;
|
_orm = orm;
|
||||||
|
@ -113,8 +113,8 @@ namespace FreeSql.Internal {
|
|||||||
}
|
}
|
||||||
trytb.Primarys = trytb.Columns.Values.Where(a => a.Attribute.IsPrimary == true).ToArray();
|
trytb.Primarys = trytb.Columns.Values.Where(a => a.Attribute.IsPrimary == true).ToArray();
|
||||||
if (trytb.Primarys.Any() == false) {
|
if (trytb.Primarys.Any() == false) {
|
||||||
var identcols = trytb.Columns.Values.Where(a => a.Attribute.IsIdentity == true).FirstOrDefault();
|
var identcol = trytb.Columns.Values.Where(a => a.Attribute.IsIdentity == true).FirstOrDefault();
|
||||||
if (identcols != null) trytb.Primarys = new[] { identcols };
|
if (identcol != null) trytb.Primarys = new[] { identcol };
|
||||||
if (trytb.Primarys.Any() == false) {
|
if (trytb.Primarys.Any() == false) {
|
||||||
trytb.Primarys = trytb.Columns.Values.Where(a => string.Compare(a.Attribute.Name, "id", true) == 0).ToArray();
|
trytb.Primarys = trytb.Columns.Values.Where(a => string.Compare(a.Attribute.Name, "id", true) == 0).ToArray();
|
||||||
if (trytb.Primarys.Any() == false) {
|
if (trytb.Primarys.Any() == false) {
|
||||||
@ -127,6 +127,34 @@ namespace FreeSql.Internal {
|
|||||||
foreach (var col in trytb.Primarys)
|
foreach (var col in trytb.Primarys)
|
||||||
col.Attribute.IsPrimary = true;
|
col.Attribute.IsPrimary = true;
|
||||||
}
|
}
|
||||||
|
//从数据库查找主键、自增
|
||||||
|
if (common.CodeFirst.IsConfigEntityFromDbFirst) {
|
||||||
|
try {
|
||||||
|
if (common._orm.DbFirst != null) {
|
||||||
|
if (common.dbTables == null)
|
||||||
|
lock (common.dbTablesLock)
|
||||||
|
if (common.dbTables == null)
|
||||||
|
common.dbTables = common._orm.DbFirst.GetTablesByDatabase();
|
||||||
|
|
||||||
|
var finddbtbs = common.dbTables.Where(a => string.Compare(a.Name, trytb.CsName, true) == 0 || string.Compare(a.Name, trytb.DbName, true) == 0);
|
||||||
|
foreach (var dbtb in finddbtbs) {
|
||||||
|
foreach (var dbident in dbtb.Identitys) {
|
||||||
|
if (trytb.Columns.TryGetValue(dbident.Name, out var trycol) && trycol.CsType == dbident.CsType ||
|
||||||
|
trytb.ColumnsByCs.TryGetValue(dbident.Name, out trycol) && trycol.CsType == dbident.CsType) {
|
||||||
|
trycol.Attribute.IsIdentity = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var dbpk in dbtb.Primarys) {
|
||||||
|
if (trytb.Columns.TryGetValue(dbpk.Name, out var trycol) && trycol.CsType == dbpk.CsType ||
|
||||||
|
trytb.ColumnsByCs.TryGetValue(dbpk.Name, out trycol) && trycol.CsType == dbpk.CsType) {
|
||||||
|
trycol.Attribute.IsPrimary = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch { }
|
||||||
|
trytb.Primarys = trytb.Columns.Values.Where(a => a.Attribute.IsPrimary == true).ToArray();
|
||||||
|
}
|
||||||
tbc.AddOrUpdate(entity, trytb, (oldkey, oldval) => trytb);
|
tbc.AddOrUpdate(entity, trytb, (oldkey, oldval) => trytb);
|
||||||
|
|
||||||
#region virtual 属性延时加载,动态产生新的重写类
|
#region virtual 属性延时加载,动态产生新的重写类
|
||||||
|
@ -26,6 +26,7 @@ namespace FreeSql.MySql {
|
|||||||
public bool IsAutoSyncStructure { get; set; } = true;
|
public bool IsAutoSyncStructure { get; set; } = true;
|
||||||
public bool IsSyncStructureToLower { get; set; } = false;
|
public bool IsSyncStructureToLower { get; set; } = false;
|
||||||
public bool IsSyncStructureToUpper { get; set; } = false;
|
public bool IsSyncStructureToUpper { get; set; } = false;
|
||||||
|
public bool IsConfigEntityFromDbFirst { get; set; } = false;
|
||||||
public bool IsLazyLoading { get; set; } = false;
|
public bool IsLazyLoading { get; set; } = false;
|
||||||
|
|
||||||
static object _dicCsToDbLock = new object();
|
static object _dicCsToDbLock = new object();
|
||||||
|
@ -136,12 +136,18 @@ namespace FreeSql.MySql {
|
|||||||
return ds.Select(a => a.FirstOrDefault()?.ToString()).ToList();
|
return ds.Select(a => a.FirstOrDefault()?.ToString()).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DbTableInfo> GetTablesByDatabase(params string[] database) {
|
public List<DbTableInfo> GetTablesByDatabase(params string[] database2) {
|
||||||
var loc1 = new List<DbTableInfo>();
|
var loc1 = new List<DbTableInfo>();
|
||||||
var loc2 = new Dictionary<string, DbTableInfo>();
|
var loc2 = new Dictionary<string, DbTableInfo>();
|
||||||
var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>();
|
var loc3 = new Dictionary<string, Dictionary<string, DbColumnInfo>>();
|
||||||
|
var database = database2?.ToArray();
|
||||||
|
|
||||||
if (database == null || database.Any() == false) return loc1;
|
if (database == null || database.Any() == false) {
|
||||||
|
using (var conn = _orm.Ado.MasterPool.Get()) {
|
||||||
|
if (string.IsNullOrEmpty(conn.Value.Database)) return loc1;
|
||||||
|
database = new[] { conn.Value.Database };
|
||||||
|
}
|
||||||
|
}
|
||||||
var databaseIn = string.Join(",", database.Select(a => "{0}".FormatMySql(a)));
|
var databaseIn = string.Join(",", database.Select(a => "{0}".FormatMySql(a)));
|
||||||
var sql = string.Format(@"
|
var sql = string.Format(@"
|
||||||
select
|
select
|
||||||
|
@ -27,6 +27,7 @@ namespace FreeSql.Oracle {
|
|||||||
public bool IsQuoteSqlName { get; set; } = true;
|
public bool IsQuoteSqlName { get; set; } = true;
|
||||||
public bool IsSyncStructureToLower { get; set; } = false;
|
public bool IsSyncStructureToLower { get; set; } = false;
|
||||||
public bool IsSyncStructureToUpper { get; set; } = false;
|
public bool IsSyncStructureToUpper { get; set; } = false;
|
||||||
|
public bool IsConfigEntityFromDbFirst { get; set; } = false;
|
||||||
public bool IsLazyLoading { get; set; } = false;
|
public bool IsLazyLoading { get; set; } = false;
|
||||||
|
|
||||||
static object _dicCsToDbLock = new object();
|
static object _dicCsToDbLock = new object();
|
||||||
|
@ -25,7 +25,7 @@ namespace FreeSql.Oracle {
|
|||||||
public IAdo Ado { get; }
|
public IAdo Ado { get; }
|
||||||
public ICache Cache { get; }
|
public ICache Cache { get; }
|
||||||
public ICodeFirst CodeFirst { get; }
|
public ICodeFirst CodeFirst { get; }
|
||||||
public IDbFirst DbFirst { get { throw new NotImplementedException(); } }
|
public IDbFirst DbFirst => null;
|
||||||
public OracleProvider(IDistributedCache cache, ILogger log, string masterConnectionString, string[] slaveConnectionString) {
|
public OracleProvider(IDistributedCache cache, ILogger log, string masterConnectionString, string[] slaveConnectionString) {
|
||||||
if (log == null) log = new LoggerFactory(new[] { new Microsoft.Extensions.Logging.Debug.DebugLoggerProvider() }).CreateLogger("FreeSql.Oracle");
|
if (log == null) log = new LoggerFactory(new[] { new Microsoft.Extensions.Logging.Debug.DebugLoggerProvider() }).CreateLogger("FreeSql.Oracle");
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ namespace FreeSql.PostgreSQL {
|
|||||||
public bool IsAutoSyncStructure { get; set; } = true;
|
public bool IsAutoSyncStructure { get; set; } = true;
|
||||||
public bool IsSyncStructureToLower { get; set; } = false;
|
public bool IsSyncStructureToLower { get; set; } = false;
|
||||||
public bool IsSyncStructureToUpper { get; set; } = false;
|
public bool IsSyncStructureToUpper { get; set; } = false;
|
||||||
|
public bool IsConfigEntityFromDbFirst { get; set; } = false;
|
||||||
public bool IsLazyLoading { get; set; } = false;
|
public bool IsLazyLoading { get; set; } = false;
|
||||||
|
|
||||||
static object _dicCsToDbLock = new object();
|
static object _dicCsToDbLock = new object();
|
||||||
|
@ -25,6 +25,7 @@ namespace FreeSql.SqlServer {
|
|||||||
public bool IsAutoSyncStructure { get; set; } = true;
|
public bool IsAutoSyncStructure { get; set; } = true;
|
||||||
public bool IsSyncStructureToLower { get; set; } = false;
|
public bool IsSyncStructureToLower { get; set; } = false;
|
||||||
public bool IsSyncStructureToUpper { get; set; } = false;
|
public bool IsSyncStructureToUpper { get; set; } = false;
|
||||||
|
public bool IsConfigEntityFromDbFirst { get; set; } = false;
|
||||||
public bool IsLazyLoading { get; set; } = false;
|
public bool IsLazyLoading { get; set; } = false;
|
||||||
|
|
||||||
static object _dicCsToDbLock = new object();
|
static object _dicCsToDbLock = new object();
|
||||||
|
@ -25,6 +25,7 @@ namespace FreeSql.Sqlite {
|
|||||||
public bool IsAutoSyncStructure { get; set; } = true;
|
public bool IsAutoSyncStructure { get; set; } = true;
|
||||||
public bool IsSyncStructureToLower { get; set; } = false;
|
public bool IsSyncStructureToLower { get; set; } = false;
|
||||||
public bool IsSyncStructureToUpper { get; set; } = false;
|
public bool IsSyncStructureToUpper { get; set; } = false;
|
||||||
|
public bool IsConfigEntityFromDbFirst { get; set; } = false;
|
||||||
public bool IsLazyLoading { get; set; } = false;
|
public bool IsLazyLoading { get; set; } = false;
|
||||||
|
|
||||||
static object _dicCsToDbLock = new object();
|
static object _dicCsToDbLock = new object();
|
||||||
|
@ -25,7 +25,7 @@ namespace FreeSql.Sqlite {
|
|||||||
public IAdo Ado { get; }
|
public IAdo Ado { get; }
|
||||||
public ICache Cache { get; }
|
public ICache Cache { get; }
|
||||||
public ICodeFirst CodeFirst { get; }
|
public ICodeFirst CodeFirst { get; }
|
||||||
public IDbFirst DbFirst { get { throw new NotImplementedException(); } }
|
public IDbFirst DbFirst => null;
|
||||||
public SqliteProvider(IDistributedCache cache, ILogger log, string masterConnectionString, string[] slaveConnectionString) {
|
public SqliteProvider(IDistributedCache cache, ILogger log, string masterConnectionString, string[] slaveConnectionString) {
|
||||||
if (log == null) log = new LoggerFactory(new[] { new Microsoft.Extensions.Logging.Debug.DebugLoggerProvider() }).CreateLogger("FreeSql.Sqlite");
|
if (log == null) log = new LoggerFactory(new[] { new Microsoft.Extensions.Logging.Debug.DebugLoggerProvider() }).CreateLogger("FreeSql.Sqlite");
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
|||||||
.UseAutoSyncStructure(true) //自动同步实体结构到数据库
|
.UseAutoSyncStructure(true) //自动同步实体结构到数据库
|
||||||
.UseSyncStructureToLower(true) //转小写同步结构
|
.UseSyncStructureToLower(true) //转小写同步结构
|
||||||
.UseSyncStructureToUpper(true) //转大写同步结构
|
.UseSyncStructureToUpper(true) //转大写同步结构
|
||||||
|
.UseConfigEntityFromDbFirst(true) //若无配置实体类主键、自增,可从数据库导入
|
||||||
|
|
||||||
.UseLazyLoading(true) //延时加载导航属性对象,导航属性需要声明 virtual
|
.UseLazyLoading(true) //延时加载导航属性对象,导航属性需要声明 virtual
|
||||||
.Build();
|
.Build();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user