mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	## v0.4.12
- 增加 .First()/.FirstAsync() 指定字段查询的重载方法 #26; - 调整 FreeSql.Repository 直接引用 FreeSql.DbContext 内的仓储实现; - 移动 FreeSql.Repository 至 FreeSql.DbContext; - 补充 单独针对 MySql 枚举类型的单元测试;
This commit is contained in:
		@@ -1,91 +0,0 @@
 | 
			
		||||
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;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace dbcontext_01
 | 
			
		||||
{
 | 
			
		||||
    public class Startup
 | 
			
		||||
    {
 | 
			
		||||
        public Startup(IConfiguration configuration, ILoggerFactory loggerFactory)
 | 
			
		||||
        {
 | 
			
		||||
            Configuration = configuration;
 | 
			
		||||
 | 
			
		||||
			Fsql = new FreeSql.FreeSqlBuilder()
 | 
			
		||||
				.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document.db;Pooling=true;Max Pool Size=10")
 | 
			
		||||
				//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=10")
 | 
			
		||||
				.UseLogger(loggerFactory.CreateLogger<IFreeSql>())
 | 
			
		||||
				.UseAutoSyncStructure(true)
 | 
			
		||||
				.UseLazyLoading(true)
 | 
			
		||||
				.UseNoneCommandParameter(true)
 | 
			
		||||
 | 
			
		||||
				.UseMonitorCommand(cmd => Trace.WriteLine(cmd.CommandText),
 | 
			
		||||
					(cmd, log) => Trace.WriteLine(log)
 | 
			
		||||
				)
 | 
			
		||||
				.Build();
 | 
			
		||||
 | 
			
		||||
			Fsql2 = new FreeSql.FreeSqlBuilder()
 | 
			
		||||
				.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\document222.db;Pooling=true;Max Pool Size=10")
 | 
			
		||||
				//.UseConnectionString(FreeSql.DataType.SqlServer, "Data Source=.;Integrated Security=True;Initial Catalog=freesqlTest;Pooling=true;Max Pool Size=10")
 | 
			
		||||
				.UseLogger(loggerFactory.CreateLogger<IFreeSql>())
 | 
			
		||||
				.UseAutoSyncStructure(true)
 | 
			
		||||
				.UseLazyLoading(true)
 | 
			
		||||
 | 
			
		||||
				.UseMonitorCommand(cmd => Trace.WriteLine(cmd.CommandText),
 | 
			
		||||
					(cmd, log) => Trace.WriteLine(log)
 | 
			
		||||
				)
 | 
			
		||||
				.Build<long>();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		enum MySql { }
 | 
			
		||||
		enum PgSql { }
 | 
			
		||||
 | 
			
		||||
		public IConfiguration Configuration { get; }
 | 
			
		||||
		public static IFreeSql Fsql { get; private set; }
 | 
			
		||||
		public static IFreeSql<long> Fsql2 { get; private set; }
 | 
			
		||||
 | 
			
		||||
		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.AddSingleton<IFreeSql>(Fsql);
 | 
			
		||||
			services.AddSingleton<IFreeSql<long>>(Fsql2);
 | 
			
		||||
			services.AddFreeDbContext<SongContext>(options => options.UseFreeSql(Fsql));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public void Configure(IApplicationBuilder app, IHostingEnvironment env, 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");
 | 
			
		||||
			});
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user