Skip to content

Commit

Permalink
- 修复 Ado.net 扩展方法 SqliteCore 支持;#1638
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Oct 18, 2023
1 parent c01416e commit 9f40805
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 22 additions & 2 deletions Examples/base_entity/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ static void Main(string[] args)
//.UseConnectionString(FreeSql.DataType.Firebird, @"database=localhost:D:\fbdata\EXAMPLES.fdb;user=sysdba;password=123456;max pool size=5")
//.UseQuoteSqlName(false)

.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true")
//.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;min pool size=1;Max pool size=3;AllowLoadLocalInfile=true")

.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")
//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=3;TrustServerCertificate=true")

//.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=2")
////.UseConnectionString(FreeSql.DataType.PostgreSQL, "Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=toc;Pooling=true;Maximum Pool Size=2")
Expand Down Expand Up @@ -600,6 +600,14 @@ static void Main(string[] args)
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
#endregion

fsql.CodeFirst.Entity<B11>(e =>
{
e.Help().Navigate(b => b.a, nameof(B11.Id));
});
fsql.CodeFirst.Entity<A11>(e => { });

var a11sql01 = fsql.Select<B11>().Where(a => a.Id == 1).ToSql(a => new { a.Name, AName = a.a.Name });

var risWorkListRepo = fsql.GetRepository<EBH_RisWorkList>();
risWorkListRepo.InsertOrUpdate(new EBH_RisWorkList
{
Expand Down Expand Up @@ -2929,4 +2937,16 @@ public class EBH_RisWorkList
public string WorkStationAddress { get; set; }


}
public class A11
{
public int Id { get; set; }
public string Name { get; set; }
}

public class B11
{
public int Id { get; set; }
public string Name { get; set; }
public A11 a { get; set; }
}
4 changes: 3 additions & 1 deletion FreeSql/Extensions/AdoNetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ static IFreeSql GetCrud(IDbConnection dbconn)
break;
case "SqlConnection":
providerType = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServer")?.MakeGenericType(connType);
if (providerType == null) throw new Exception(CoreStrings.Missing_FreeSqlProvider_Package("SqlServer"));
if (providerType == null) providerType = Type.GetType("FreeSql.SqlServer.SqlServerProvider`1,FreeSql.Provider.SqlServerForSystem")?.MakeGenericType(connType);
if (providerType == null) throw new Exception(CoreStrings.Missing_FreeSqlProvider_Package("SqlServer/SqlServerForSystem"));
break;
case "NpgsqlConnection":
providerType = Type.GetType("FreeSql.PostgreSQL.PostgreSQLProvider`1,FreeSql.Provider.PostgreSQL")?.MakeGenericType(connType);
Expand All @@ -42,6 +43,7 @@ static IFreeSql GetCrud(IDbConnection dbconn)
case "SQLiteConnection":
case "SqliteConnection":
providerType = Type.GetType("FreeSql.Sqlite.SqliteProvider`1,FreeSql.Provider.Sqlite")?.MakeGenericType(connType);
if (providerType == null) providerType = Type.GetType("FreeSql.Sqlite.SqliteProvider`1,FreeSql.Provider.SqliteCore")?.MakeGenericType(connType); //Microsoft.Data.Sqlite.Core.dll
if (providerType == null) throw new Exception(CoreStrings.Missing_FreeSqlProvider_Package("Sqlite/SqliteCore"));
break;
case "DmConnection":
Expand Down

0 comments on commit 9f40805

Please sign in to comment.