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,67 +0,0 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Diagnostics;
 | 
			
		||||
using System.IO;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Numerics;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using FreeSql;
 | 
			
		||||
using FreeSql.DataAnnotations;
 | 
			
		||||
using Microsoft.AspNetCore;
 | 
			
		||||
using Microsoft.AspNetCore.Hosting;
 | 
			
		||||
using Microsoft.Extensions.Configuration;
 | 
			
		||||
using Microsoft.Extensions.Logging;
 | 
			
		||||
 | 
			
		||||
namespace dbcontext_01
 | 
			
		||||
{
 | 
			
		||||
    public class Program
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
		public class Song {
 | 
			
		||||
			[Column(IsIdentity = true)]
 | 
			
		||||
			public int Id { get; set; }
 | 
			
		||||
			public string BigNumber { get; set; }
 | 
			
		||||
 | 
			
		||||
			[Column(IsVersion = true)]//使用简单
 | 
			
		||||
			public long versionRow { get; set; }
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public class SongContext : DbContext {
 | 
			
		||||
 | 
			
		||||
			public DbSet<Song> Songs { get; set; }
 | 
			
		||||
 | 
			
		||||
			protected override void OnConfiguring(DbContextOptionsBuilder builder) {
 | 
			
		||||
				builder.UseFreeSql(fsql);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		static IFreeSql fsql;
 | 
			
		||||
		public static void Main(string[] args) {
 | 
			
		||||
			fsql = new FreeSql.FreeSqlBuilder()
 | 
			
		||||
				.UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\dd2.db;Pooling=true;Max Pool Size=10")
 | 
			
		||||
				.UseAutoSyncStructure(true)
 | 
			
		||||
				.UseLazyLoading(true)
 | 
			
		||||
				.UseNoneCommandParameter(true)
 | 
			
		||||
 | 
			
		||||
				.UseMonitorCommand(cmd => Trace.WriteLine(cmd.CommandText))
 | 
			
		||||
				.Build();
 | 
			
		||||
 | 
			
		||||
			using (var ctx = new SongContext()) {
 | 
			
		||||
				var song = new Song { BigNumber = "1000000000000000000" };
 | 
			
		||||
				ctx.Songs.Add(song);
 | 
			
		||||
 | 
			
		||||
				ctx.Songs.Update(song);
 | 
			
		||||
 | 
			
		||||
				song.BigNumber = (BigInteger.Parse(song.BigNumber) + 1).ToString();
 | 
			
		||||
				ctx.Songs.Update(song);
 | 
			
		||||
 | 
			
		||||
				ctx.SaveChanges();
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			CreateWebHostBuilder(args).Build().Run();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
 | 
			
		||||
            WebHost.CreateDefaultBuilder(args)
 | 
			
		||||
                .UseStartup<Startup>();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user