From 3a889504fb66cb7cfc0ab19f2f0ccb5f9c1a2685 Mon Sep 17 00:00:00 2001
From: 28810 <28810@YEXIANGQIN>
Date: Wed, 11 Dec 2019 22:11:27 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E7=A4=BA=E4=BE=8B=E9=A1=B9=E7=9B=AE?=
=?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=8D=87=E7=BA=A7=E4=B8=BA=20.net=20core=203?=
=?UTF-8?q?.1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Examples/base_entity/Program.cs | 2 +
Examples/base_entity/base_entity.csproj | 2 +-
Examples/benchmarker/Program.cs | 3 -
Examples/benchmarker/benchmarker.csproj | 8 +--
Examples/dbcontext_01/Startup.cs | 30 ++-------
Examples/dbcontext_01/dbcontext_01.csproj | 7 +-
.../FreeSqlExtensions/CodeFirstExtensions.cs | 2 +-
Examples/efcore_to_freesql/Startup.cs | 7 +-
.../efcore_to_freesql.csproj | 5 +-
Examples/orm_vs/orm_vs.csproj | 2 +-
Examples/orm_vs_net40/orm_vs_net40.csproj | 2 +-
Examples/repository_01/Startup.cs | 31 ++-------
Examples/repository_01/repository_01.csproj | 10 ++-
Examples/restful/Startup.cs | 28 ++------
Examples/restful/restful.csproj | 8 +--
.../FreeSql.Tests.DbContext.csproj | 2 +-
.../FreeSql.Tests.PerformanceTests.csproj | 2 +-
...eeSql.Tests.Provider.MySqlConnector.csproj | 2 +-
.../FreeSql.Tests.Provider.Odbc.csproj | 2 +-
.../FreeSql.Tests/FreeSql.Tests.csproj | 2 +-
FreeSql.Tests/FreeSql.Tests/UnitTest3.cs | 64 +++++++++++++++++++
21 files changed, 104 insertions(+), 117 deletions(-)
create mode 100644 FreeSql.Tests/FreeSql.Tests/UnitTest3.cs
diff --git a/Examples/base_entity/Program.cs b/Examples/base_entity/Program.cs
index 798ea5c3..6f43a2e8 100644
--- a/Examples/base_entity/Program.cs
+++ b/Examples/base_entity/Program.cs
@@ -4,6 +4,7 @@ using FreeSql.Extensions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
+using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Threading;
@@ -35,6 +36,7 @@ namespace base_entity
static void Main(string[] args)
{
+
#region 初始化 IFreeSql
var fsql = new FreeSql.FreeSqlBuilder()
.UseAutoSyncStructure(true)
diff --git a/Examples/base_entity/base_entity.csproj b/Examples/base_entity/base_entity.csproj
index 2df960d9..7289cf02 100644
--- a/Examples/base_entity/base_entity.csproj
+++ b/Examples/base_entity/base_entity.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/Examples/benchmarker/Program.cs b/Examples/benchmarker/Program.cs
index c7f00f27..d4fa9473 100644
--- a/Examples/benchmarker/Program.cs
+++ b/Examples/benchmarker/Program.cs
@@ -53,7 +53,6 @@ namespace FreeSql.Bechmarker
}
}
- [CoreJob]
[RPlotExporter, RankColumn]
public class OrmVsInsert
{
@@ -111,7 +110,6 @@ namespace FreeSql.Bechmarker
}
}
- [CoreJob]
[RPlotExporter, RankColumn]
public class OrmVsUpdate
{
@@ -144,7 +142,6 @@ namespace FreeSql.Bechmarker
}
}
- [CoreJob]
[RPlotExporter, RankColumn]
public class OrmVsSelect
{
diff --git a/Examples/benchmarker/benchmarker.csproj b/Examples/benchmarker/benchmarker.csproj
index 958667bd..bcc5dc7d 100644
--- a/Examples/benchmarker/benchmarker.csproj
+++ b/Examples/benchmarker/benchmarker.csproj
@@ -2,13 +2,13 @@
Exe
- netcoreapp2.1
+ netcoreapp3.1
-
-
-
+
+
+
diff --git a/Examples/dbcontext_01/Startup.cs b/Examples/dbcontext_01/Startup.cs
index 181e9068..777f8be3 100644
--- a/Examples/dbcontext_01/Startup.cs
+++ b/Examples/dbcontext_01/Startup.cs
@@ -1,11 +1,8 @@
using FreeSql;
-using FreeSql.DataAnnotations;
using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Diagnostics;
using System.Linq;
@@ -73,18 +70,7 @@ namespace dbcontext_01
public void ConfigureServices(IServiceCollection services)
{
- services.AddMvc();
- services.AddSwaggerGen(options =>
- {
- options.SwaggerDoc("v1", new Info
- {
- Version = "v1",
- Title = "FreeSql.DbContext API"
- });
- //options.IncludeXmlComments(xmlPath);
- });
-
-
+ services.AddControllersWithViews();
services.AddSingleton(Fsql);
services.AddSingleton>(Fsql2);
@@ -96,24 +82,16 @@ namespace dbcontext_01
var sql3 = Fsql.Update(1).Set(a => a.Create_time.Value.AddHours(1)).ToSql();
}
- public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
+ public void Configure(IApplicationBuilder app)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Console.OutputEncoding = Encoding.GetEncoding("GB2312");
Console.InputEncoding = Encoding.GetEncoding("GB2312");
- loggerFactory.AddConsole(Configuration.GetSection("Logging"));
- loggerFactory.AddDebug();
-
app.UseHttpMethodOverride(new HttpMethodOverrideOptions { FormFieldName = "X-Http-Method-Override" });
app.UseDeveloperExceptionPage();
- app.UseMvc();
-
- app.UseSwagger();
- app.UseSwaggerUI(c =>
- {
- c.SwaggerEndpoint("/swagger/v1/swagger.json", "FreeSql.RESTful API V1");
- });
+ app.UseRouting();
+ app.UseEndpoints(a => a.MapControllers());
}
}
}
diff --git a/Examples/dbcontext_01/dbcontext_01.csproj b/Examples/dbcontext_01/dbcontext_01.csproj
index a90702b5..516f4a05 100644
--- a/Examples/dbcontext_01/dbcontext_01.csproj
+++ b/Examples/dbcontext_01/dbcontext_01.csproj
@@ -1,15 +1,12 @@
- netcoreapp2.1
+ netcoreapp3.1
InProcess
-
-
-
-
+
diff --git a/Examples/efcore_to_freesql/FreeSqlExtensions/CodeFirstExtensions.cs b/Examples/efcore_to_freesql/FreeSqlExtensions/CodeFirstExtensions.cs
index 1c6d5e68..096f5b9f 100644
--- a/Examples/efcore_to_freesql/FreeSqlExtensions/CodeFirstExtensions.cs
+++ b/Examples/efcore_to_freesql/FreeSqlExtensions/CodeFirstExtensions.cs
@@ -47,7 +47,7 @@ public static class CodeFirstExtensions
);
//可空
- freeProp.IsNullable(prop.AfterSaveBehavior != PropertySaveBehavior.Throw);
+ freeProp.IsNullable(prop.GetAfterSaveBehavior() != PropertySaveBehavior.Throw);
//类型
var relationalColumnType = prop.FindAnnotation("Relational:ColumnType");
diff --git a/Examples/efcore_to_freesql/Startup.cs b/Examples/efcore_to_freesql/Startup.cs
index 0e9eea21..0fabf866 100644
--- a/Examples/efcore_to_freesql/Startup.cs
+++ b/Examples/efcore_to_freesql/Startup.cs
@@ -68,13 +68,10 @@ namespace efcore_to_freesql
services.AddMvc();
}
- public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
+ public void Configure(IApplicationBuilder app)
{
- loggerFactory.AddConsole(Configuration.GetSection("Logging"));
- loggerFactory.AddDebug();
-
app.UseDeveloperExceptionPage();
- app.UseMvc();
+ app.UseEndpoints(a => a.MapControllers());
}
}
}
diff --git a/Examples/efcore_to_freesql/efcore_to_freesql.csproj b/Examples/efcore_to_freesql/efcore_to_freesql.csproj
index 4516a3f9..3769825e 100644
--- a/Examples/efcore_to_freesql/efcore_to_freesql.csproj
+++ b/Examples/efcore_to_freesql/efcore_to_freesql.csproj
@@ -1,13 +1,12 @@
- netcoreapp2.1
+ netcoreapp3.1
InProcess
-
-
+
diff --git a/Examples/orm_vs/orm_vs.csproj b/Examples/orm_vs/orm_vs.csproj
index a36447e3..4e6eb813 100644
--- a/Examples/orm_vs/orm_vs.csproj
+++ b/Examples/orm_vs/orm_vs.csproj
@@ -2,7 +2,7 @@
Exe
- netcoreapp2.1
+ netcoreapp3.1
diff --git a/Examples/orm_vs_net40/orm_vs_net40.csproj b/Examples/orm_vs_net40/orm_vs_net40.csproj
index 581a3ccb..15ca534f 100644
--- a/Examples/orm_vs_net40/orm_vs_net40.csproj
+++ b/Examples/orm_vs_net40/orm_vs_net40.csproj
@@ -60,7 +60,7 @@
- 12.0.2
+ 12.0.3
diff --git a/Examples/repository_01/Startup.cs b/Examples/repository_01/Startup.cs
index 24b5b025..65bb13c2 100644
--- a/Examples/repository_01/Startup.cs
+++ b/Examples/repository_01/Startup.cs
@@ -1,16 +1,11 @@
using FreeSql;
using FreeSql.DataAnnotations;
using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using restful.Entitys;
-using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Diagnostics;
-using System.Linq;
using System.Text;
namespace repository_01
@@ -61,17 +56,7 @@ namespace repository_01
//services.AddTransient(s => s.)
- services.AddMvc();
- services.AddSwaggerGen(options =>
- {
- options.SwaggerDoc("v1", new Info
- {
- Version = "v1",
- Title = "FreeSql.RESTful API"
- });
- //options.IncludeXmlComments(xmlPath);
- });
-
+ services.AddControllersWithViews();
services.AddSingleton(Fsql);
services.AddFreeRepository(filter =>
@@ -82,24 +67,16 @@ namespace repository_01
}, this.GetType().Assembly);
}
- public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
+ public void Configure(IApplicationBuilder app)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Console.OutputEncoding = Encoding.GetEncoding("GB2312");
Console.InputEncoding = Encoding.GetEncoding("GB2312");
- loggerFactory.AddConsole(Configuration.GetSection("Logging"));
- loggerFactory.AddDebug();
-
app.UseHttpMethodOverride(new HttpMethodOverrideOptions { FormFieldName = "X-Http-Method-Override" });
app.UseDeveloperExceptionPage();
- app.UseMvc();
-
- app.UseSwagger();
- app.UseSwaggerUI(c =>
- {
- c.SwaggerEndpoint("/swagger/v1/swagger.json", "FreeSql.RESTful API V1");
- });
+ app.UseRouting();
+ app.UseEndpoints(a => a.MapControllers());
}
}
diff --git a/Examples/repository_01/repository_01.csproj b/Examples/repository_01/repository_01.csproj
index 4c63f521..fce8cda4 100644
--- a/Examples/repository_01/repository_01.csproj
+++ b/Examples/repository_01/repository_01.csproj
@@ -1,20 +1,18 @@
- netcoreapp2.1
+ netcoreapp3.1
InProcess
-
-
-
-
-
+
+
+
diff --git a/Examples/restful/Startup.cs b/Examples/restful/Startup.cs
index 89e8977e..6079ae39 100644
--- a/Examples/restful/Startup.cs
+++ b/Examples/restful/Startup.cs
@@ -1,9 +1,7 @@
using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Text;
@@ -41,37 +39,19 @@ namespace restful
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(Fsql);
-
- services.AddMvc();
- services.AddSwaggerGen(options =>
- {
- options.SwaggerDoc("v1", new Info
- {
- Version = "v1",
- Title = "FreeSql.RESTful API"
- });
- //options.IncludeXmlComments(xmlPath);
- });
+ services.AddControllersWithViews();
}
- public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
+ public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Console.OutputEncoding = Encoding.GetEncoding("GB2312");
Console.InputEncoding = Encoding.GetEncoding("GB2312");
- loggerFactory.AddConsole(Configuration.GetSection("Logging"));
- loggerFactory.AddDebug();
-
app.UseHttpMethodOverride(new HttpMethodOverrideOptions { FormFieldName = "X-Http-Method-Override" });
app.UseDeveloperExceptionPage();
- app.UseMvc();
-
- app.UseSwagger();
- app.UseSwaggerUI(c =>
- {
- c.SwaggerEndpoint("/swagger/v1/swagger.json", "FreeSql.RESTful API V1");
- });
+ app.UseRouting();
+ app.UseEndpoints(a => a.MapControllers());
}
}
}
diff --git a/Examples/restful/restful.csproj b/Examples/restful/restful.csproj
index 0963a30d..67461b06 100644
--- a/Examples/restful/restful.csproj
+++ b/Examples/restful/restful.csproj
@@ -1,19 +1,17 @@
- netcoreapp2.1
+ netcoreapp3.1
InProcess
-
-
-
-
+
+
diff --git a/FreeSql.Tests/FreeSql.Tests.DbContext/FreeSql.Tests.DbContext.csproj b/FreeSql.Tests/FreeSql.Tests.DbContext/FreeSql.Tests.DbContext.csproj
index 761bebcf..bda7efbb 100644
--- a/FreeSql.Tests/FreeSql.Tests.DbContext/FreeSql.Tests.DbContext.csproj
+++ b/FreeSql.Tests/FreeSql.Tests.DbContext/FreeSql.Tests.DbContext.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1
+ netcoreapp3.1
false
diff --git a/FreeSql.Tests/FreeSql.Tests.PerformanceTests/FreeSql.Tests.PerformanceTests.csproj b/FreeSql.Tests/FreeSql.Tests.PerformanceTests/FreeSql.Tests.PerformanceTests.csproj
index afdd5535..a3e53b3c 100644
--- a/FreeSql.Tests/FreeSql.Tests.PerformanceTests/FreeSql.Tests.PerformanceTests.csproj
+++ b/FreeSql.Tests/FreeSql.Tests.PerformanceTests/FreeSql.Tests.PerformanceTests.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1
+ netcoreapp3.1
false
diff --git a/FreeSql.Tests/FreeSql.Tests.Provider.MySqlConnector/FreeSql.Tests.Provider.MySqlConnector.csproj b/FreeSql.Tests/FreeSql.Tests.Provider.MySqlConnector/FreeSql.Tests.Provider.MySqlConnector.csproj
index 314fab71..bb1fc44e 100644
--- a/FreeSql.Tests/FreeSql.Tests.Provider.MySqlConnector/FreeSql.Tests.Provider.MySqlConnector.csproj
+++ b/FreeSql.Tests/FreeSql.Tests.Provider.MySqlConnector/FreeSql.Tests.Provider.MySqlConnector.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1
+ netcoreapp3.1
false
diff --git a/FreeSql.Tests/FreeSql.Tests.Provider.Odbc/FreeSql.Tests.Provider.Odbc.csproj b/FreeSql.Tests/FreeSql.Tests.Provider.Odbc/FreeSql.Tests.Provider.Odbc.csproj
index 3e1c4df1..3ece19a4 100644
--- a/FreeSql.Tests/FreeSql.Tests.Provider.Odbc/FreeSql.Tests.Provider.Odbc.csproj
+++ b/FreeSql.Tests/FreeSql.Tests.Provider.Odbc/FreeSql.Tests.Provider.Odbc.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1
+ netcoreapp3.1
false
diff --git a/FreeSql.Tests/FreeSql.Tests/FreeSql.Tests.csproj b/FreeSql.Tests/FreeSql.Tests/FreeSql.Tests.csproj
index 364e968d..c895f7f6 100644
--- a/FreeSql.Tests/FreeSql.Tests/FreeSql.Tests.csproj
+++ b/FreeSql.Tests/FreeSql.Tests/FreeSql.Tests.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.1
+ netcoreapp3.1
false
diff --git a/FreeSql.Tests/FreeSql.Tests/UnitTest3.cs b/FreeSql.Tests/FreeSql.Tests/UnitTest3.cs
new file mode 100644
index 00000000..4a6d3519
--- /dev/null
+++ b/FreeSql.Tests/FreeSql.Tests/UnitTest3.cs
@@ -0,0 +1,64 @@
+using FreeSql.DataAnnotations;
+using FreeSql;
+using System;
+using System.Collections.Generic;
+using Xunit;
+using System.Linq;
+using Newtonsoft.Json.Linq;
+using NpgsqlTypes;
+using Npgsql.LegacyPostgis;
+using System.Linq.Expressions;
+using System.Threading.Tasks;
+using System.ComponentModel.DataAnnotations;
+using System.Threading;
+using System.Data.SqlClient;
+using kwlib;
+using System.Diagnostics;
+
+namespace FreeSql.Tests
+{
+ public class UnitTest3
+ {
+
+ [Fact]
+ public void Test03()
+ {
+ //using (var conn = new SqlConnection("Data Source=.;Integrated Security=True;Initial Catalog=webchat-abc;Pooling=true;Max Pool Size=13"))
+ //{
+ // conn.Open();
+ // conn.Close();
+ //}
+
+ //using (var fsql = new FreeSql.FreeSqlBuilder()
+ // .UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=webchat-abc;Pooling=true;Max Pool Size=13")
+ // .UseAutoSyncStructure(true)
+ // //.UseGenerateCommandParameterWithLambda(true)
+ // .UseMonitorCommand(
+ // cmd => Trace.WriteLine("\r\n线程" + Thread.CurrentThread.ManagedThreadId + ": " + cmd.CommandText) //监听SQL命令对象,在执行前
+ // //, (cmd, traceLog) => Console.WriteLine(traceLog)
+ // )
+ // .UseLazyLoading(true)
+ // .Build())
+ //{
+ // fsql.Select().ToList();
+ //}
+
+
+ }
+
+ class ut3_t1
+ {
+ [Column(IsIdentity = true)]
+ public int id { get; set; }
+ public string name { get; set; }
+ }
+
+ class ut3_t2
+ {
+ [Column(IsIdentity = true)]
+ public int id { get; set; }
+ public string name { get; set; }
+ }
+ }
+
+}