mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 增加 IInsert.ExecuteSqlBulkCopy 扩展方法执行 SqlBulkCopy 批量插入,在 FreeSql.Provider.SqlServer 可用;
This commit is contained in:
		@@ -910,6 +910,15 @@
 | 
			
		||||
            </summary>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:FreeSql.IInsert`1.ToDataTable">
 | 
			
		||||
            <summary>
 | 
			
		||||
            返回 DataTable 以便做 BulkCopy 数据做准备<para></para>
 | 
			
		||||
            此方法会处理:<para></para>
 | 
			
		||||
            类型、表名、字段名映射<para></para>
 | 
			
		||||
            IgnoreColumns、InsertColumns
 | 
			
		||||
            </summary>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="F:FreeSql.FieldAliasOptions.AsIndex">
 | 
			
		||||
            <summary>
 | 
			
		||||
            自动产生 as1, as2, as3 .... 字段别名<para></para>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
using FreeSql.Internal.Model;
 | 
			
		||||
using FreeSql.Extensions.EntityUtil;
 | 
			
		||||
using SafeObjectPool;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
@@ -136,8 +137,20 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
            foreach (var col in table.Columns.Values)
 | 
			
		||||
            {
 | 
			
		||||
                object val = col.GetMapValue(data);
 | 
			
		||||
                if (col.Attribute.IsPrimary && col.Attribute.MapType.NullableTypeOrThis() == typeof(Guid) && (val == null || (Guid)val == Guid.Empty))
 | 
			
		||||
                    col.SetMapValue(data, val = FreeUtil.NewMongodbId());
 | 
			
		||||
                if (col.Attribute.IsPrimary)
 | 
			
		||||
                {
 | 
			
		||||
                    if (col.Attribute.MapType.NullableTypeOrThis() == typeof(Guid) && (val == null || (Guid)val == Guid.Empty))
 | 
			
		||||
                        col.SetMapValue(data, val = FreeUtil.NewMongodbId());
 | 
			
		||||
                    else if (col.CsType.NullableTypeOrThis() == typeof(Guid))
 | 
			
		||||
                    {
 | 
			
		||||
                        var guidVal = orm.GetEntityValueWithPropertyName(table.Type, data, col.CsName);
 | 
			
		||||
                        if (guidVal == null || (Guid)guidVal == Guid.Empty)
 | 
			
		||||
                        {
 | 
			
		||||
                            orm.SetEntityValueWithPropertyName(table.Type, data, col.CsName, FreeUtil.NewMongodbId());
 | 
			
		||||
                            val = col.GetMapValue(data);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (orm.Aop.AuditValue != null)
 | 
			
		||||
                {
 | 
			
		||||
                    var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.Insert, col, table.Properties[col.CsName], val);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user