mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
内部 ColumnInfo 调整
This commit is contained in:
parent
90b6d76510
commit
8cec3e396b
@ -50,6 +50,15 @@ namespace orm_vs
|
|||||||
//optionsBuilder.UseMySql("Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Min Pool Size=21;Max Pool Size=21");
|
//optionsBuilder.UseMySql("Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Min Pool Size=21;Max Pool Size=21");
|
||||||
//optionsBuilder.UseNpgsql("Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=21");
|
//optionsBuilder.UseNpgsql("Host=192.168.164.10;Port=5432;Username=postgres;Password=123456;Database=tedb;Pooling=true;Maximum Pool Size=21");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Song>()
|
||||||
|
.Property(a => a.create_time)
|
||||||
|
.HasConversion(a => int.Parse(a.ToString()), a => new DateTime(a));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
|
@ -130,13 +130,6 @@
|
|||||||
清空状态数据
|
清空状态数据
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
|
|
||||||
<summary>
|
|
||||||
根据 lambda 条件删除数据
|
|
||||||
</summary>
|
|
||||||
<param name="predicate"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
||||||
<summary>
|
<summary>
|
||||||
添加
|
添加
|
||||||
@ -532,14 +525,5 @@
|
|||||||
<param name="that"></param>
|
<param name="that"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
|
||||||
<summary>
|
|
||||||
批量注入 Repository,可以参考代码自行调整
|
|
||||||
</summary>
|
|
||||||
<param name="services"></param>
|
|
||||||
<param name="globalDataFilter"></param>
|
|
||||||
<param name="assemblies"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
@ -332,6 +332,9 @@ namespace FreeSql.Tests
|
|||||||
cts[1].Goodss.Add(new Goods { Name = "商品55" });
|
cts[1].Goodss.Add(new Goods { Name = "商品55" });
|
||||||
repo.Update(cts);
|
repo.Update(cts);
|
||||||
|
|
||||||
|
var cts2 = repo.Select.WhereDynamic(cts).IncludeMany(a => a.Goodss).ToList();
|
||||||
|
cts2[0].Goodss[0].Name += 123;
|
||||||
|
repo.Update(cts2[0]);
|
||||||
}
|
}
|
||||||
[Table(Name = "EAUNL_OTM_CT")]
|
[Table(Name = "EAUNL_OTM_CT")]
|
||||||
class Cagetory
|
class Cagetory
|
||||||
@ -490,7 +493,9 @@ namespace FreeSql.Tests
|
|||||||
var repo = g.sqlite.GetRepository<Song>();
|
var repo = g.sqlite.GetRepository<Song>();
|
||||||
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true; //打开级联保存功能
|
repo.DbContextOptions.EnableAddOrUpdateNavigateList = true; //打开级联保存功能
|
||||||
repo.Insert(ss);
|
repo.Insert(ss);
|
||||||
//repo.SaveMany(ss[0], "Tags"); //指定保存 Tags 多对多属性
|
|
||||||
|
ss[0].Tags[0].TagName = "流行101";
|
||||||
|
repo.SaveMany(ss[0], "Tags"); //指定保存 Tags 多对多属性
|
||||||
|
|
||||||
ss[0].Name = "爱你一万年.mp5";
|
ss[0].Name = "爱你一万年.mp5";
|
||||||
ss[0].Tags.Clear();
|
ss[0].Tags.Clear();
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
|
using FreeSql.Internal.CommonProvider;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Intrinsics.X86;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace FreeSql.Tests.MySql
|
namespace FreeSql.Tests.MySql
|
||||||
@ -1311,6 +1313,15 @@ WHERE ((b.`IsFinished` OR a.`TaskType` = 3) AND b.`EnabledMark` = 1)", groupsql1
|
|||||||
};
|
};
|
||||||
Assert.Equal(5, g.mysql.Insert(model4s).ExecuteAffrows());
|
Assert.Equal(5, g.mysql.Insert(model4s).ExecuteAffrows());
|
||||||
|
|
||||||
|
var sel = g.mysql.Select<TestInclude_OneToManyModel2, TestInclude_OneToManyModel3>();
|
||||||
|
//var tb1 = (sel as Select0Provider)._tables[1];
|
||||||
|
//tb1.Type = Internal.Model.SelectTableInfoType.LeftJoin;
|
||||||
|
//tb1.On = $"b.id = ({g.mysql.Select<TestInclude_OneToManyModel3>().As("b2").Where("a.model2id = model2111Idaaa").Limit(1).ToSql("id")})";
|
||||||
|
var sql = sel
|
||||||
|
.LeftJoin((a,b) => b.id == g.mysql.Select<TestInclude_OneToManyModel3>().As("b2").Where(b2 => a.model2id == b2.model2111Idaaa).First(b2 => b2.id))
|
||||||
|
.ToSql((a, b) => new { a, b });
|
||||||
|
|
||||||
|
|
||||||
var t0 = g.mysql.Select<TestInclude_OneToManyModel2>()
|
var t0 = g.mysql.Select<TestInclude_OneToManyModel2>()
|
||||||
.IncludeMany(a => a.childs.Where(m3 => m3.model2111Idaaa == a.model2id))
|
.IncludeMany(a => a.childs.Where(m3 => m3.model2111Idaaa == a.model2id))
|
||||||
.Where(a => a.model2id <= model1.id)
|
.Where(a => a.model2id <= model1.id)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using FreeSql.Internal.Model;
|
||||||
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -27,7 +28,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="genGuid">当Guid无值时,会生成有序的新值</param>
|
/// <param name="genGuid">当Guid无值时,会生成有序的新值</param>
|
||||||
/// <param name="splitString"></param>
|
/// <param name="splitString"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//public static string GetEntityKeyString<TEntity>(this IFreeSql orm, TEntity entity, string splitString = "*|_,[,_|*") => GetEntityKeyString(orm, typeof(TEntity), entity, splitString);
|
|
||||||
public static string GetEntityKeyString(this IFreeSql orm, Type entityType, object entity, bool genGuid, string splitString = "*|_,[,_|*")
|
public static string GetEntityKeyString(this IFreeSql orm, Type entityType, object entity, bool genGuid, string splitString = "*|_,[,_|*")
|
||||||
{
|
{
|
||||||
if (entity == null) return null;
|
if (entity == null) return null;
|
||||||
@ -141,7 +141,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="entityType"></param>
|
/// <param name="entityType"></param>
|
||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//public static object[] GetEntityKeyValues<TEntity>(this IFreeSql orm, TEntity entity) => GetEntityKeyValues(orm, typeof(TEntity), entity);
|
|
||||||
public static object[] GetEntityKeyValues(this IFreeSql orm, Type entityType, object entity)
|
public static object[] GetEntityKeyValues(this IFreeSql orm, Type entityType, object entity)
|
||||||
{
|
{
|
||||||
if (entity == null) return null;
|
if (entity == null) return null;
|
||||||
@ -184,7 +183,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <param name="propertyName"></param>
|
/// <param name="propertyName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//public static object GetEntityValueWithPropertyName<TEntity>(this IFreeSql orm, TEntity entity, string propertyName) => GetEntityKeyValues(orm, typeof(TEntity), entity, propertyName);
|
|
||||||
public static object GetEntityValueWithPropertyName(this IFreeSql orm, Type entityType, object entity, string propertyName)
|
public static object GetEntityValueWithPropertyName(this IFreeSql orm, Type entityType, object entity, string propertyName)
|
||||||
{
|
{
|
||||||
if (entity == null) return null;
|
if (entity == null) return null;
|
||||||
@ -194,8 +192,8 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
.GetOrAdd(entityType, et => new ConcurrentDictionary<string, Func<object, object>>())
|
.GetOrAdd(entityType, et => new ConcurrentDictionary<string, Func<object, object>>())
|
||||||
.GetOrAdd(propertyName, pn =>
|
.GetOrAdd(propertyName, pn =>
|
||||||
{
|
{
|
||||||
var _table = orm.CodeFirst.GetTableByEntity(entityType);
|
var table = orm.CodeFirst.GetTableByEntity(entityType);
|
||||||
var pks = _table.Primarys;
|
var pks = table.Primarys;
|
||||||
var returnTarget = Expression.Label(typeof(object));
|
var returnTarget = Expression.Label(typeof(object));
|
||||||
var parm1 = Expression.Parameter(typeof(object));
|
var parm1 = Expression.Parameter(typeof(object));
|
||||||
var var1Parm = Expression.Variable(entityType);
|
var var1Parm = Expression.Variable(entityType);
|
||||||
@ -204,7 +202,35 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
Expression.Assign(var1Parm, Expression.TypeAs(parm1, entityType)),
|
Expression.Assign(var1Parm, Expression.TypeAs(parm1, entityType)),
|
||||||
Expression.Assign(
|
Expression.Assign(
|
||||||
var2Ret,
|
var2Ret,
|
||||||
Expression.Convert(Expression.MakeMemberAccess(var1Parm, _table.Properties[pn]), typeof(object))
|
Expression.Convert(Expression.MakeMemberAccess(var1Parm, table.Properties[pn]), typeof(object))
|
||||||
|
)
|
||||||
|
});
|
||||||
|
exps.AddRange(new Expression[] {
|
||||||
|
Expression.Return(returnTarget, var2Ret),
|
||||||
|
Expression.Label(returnTarget, Expression.Default(typeof(object)))
|
||||||
|
});
|
||||||
|
return Expression.Lambda<Func<object, object>>(Expression.Block(new[] { var1Parm, var2Ret }, exps), new[] { parm1 }).Compile();
|
||||||
|
});
|
||||||
|
return func(entity);
|
||||||
|
}
|
||||||
|
public static object GetPropertyValue(this TableInfo table, object entity, string propertyName)
|
||||||
|
{
|
||||||
|
if (table == null || entity == null) return null;
|
||||||
|
var func = _dicGetEntityValueWithPropertyName
|
||||||
|
.GetOrAdd(DataType.MsAccess, dt => new ConcurrentDictionary<Type, ConcurrentDictionary<string, Func<object, object>>>())
|
||||||
|
.GetOrAdd(table.Type, et => new ConcurrentDictionary<string, Func<object, object>>())
|
||||||
|
.GetOrAdd(propertyName, pn =>
|
||||||
|
{
|
||||||
|
var pks = table.Primarys;
|
||||||
|
var returnTarget = Expression.Label(typeof(object));
|
||||||
|
var parm1 = Expression.Parameter(typeof(object));
|
||||||
|
var var1Parm = Expression.Variable(table.Type);
|
||||||
|
var var2Ret = Expression.Variable(typeof(object));
|
||||||
|
var exps = new List<Expression>(new Expression[] {
|
||||||
|
Expression.Assign(var1Parm, Expression.TypeAs(parm1, table.Type)),
|
||||||
|
Expression.Assign(
|
||||||
|
var2Ret,
|
||||||
|
Expression.Convert(Expression.MakeMemberAccess(var1Parm, table.Properties[pn]), typeof(object))
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
exps.AddRange(new Expression[] {
|
exps.AddRange(new Expression[] {
|
||||||
@ -223,7 +249,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="entityType"></param>
|
/// <param name="entityType"></param>
|
||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//public static string GetEntityString<TEntity>(this IFreeSql orm, TEntity entity) => GetEntityString(orm, typeof(TEntity), entity);
|
|
||||||
public static string GetEntityString(this IFreeSql orm, Type entityType, object entity)
|
public static string GetEntityString(this IFreeSql orm, Type entityType, object entity)
|
||||||
{
|
{
|
||||||
if (entity == null) return null;
|
if (entity == null) return null;
|
||||||
@ -270,7 +295,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// 使用新实体的值,复盖旧实体的值
|
/// 使用新实体的值,复盖旧实体的值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, object>>> _dicMapEntityValue = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, object>>>();
|
static ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, object>>> _dicMapEntityValue = new ConcurrentDictionary<DataType, ConcurrentDictionary<Type, Action<object, object>>>();
|
||||||
//public static void MapEntityValue<TEntity>(this IFreeSql orm, TEntity entityFrom, TEntity entityTo) => MapEntityValue(orm, typeof(TEntity), entityFrom, entityTo);
|
|
||||||
public static void MapEntityValue(this IFreeSql orm, Type entityType, object entityFrom, object entityTo)
|
public static void MapEntityValue(this IFreeSql orm, Type entityType, object entityFrom, object entityTo)
|
||||||
{
|
{
|
||||||
if (entityType == null) entityType = entityFrom?.GetType() ?? entityTo?.GetType();
|
if (entityType == null) entityType = entityFrom?.GetType() ?? entityTo?.GetType();
|
||||||
@ -316,7 +340,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 使用新实体的主键值,复盖旧实体的主键值
|
/// 使用新实体的主键值,复盖旧实体的主键值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//public static void MapEntityKeyValue<TEntity>(this IFreeSql orm, TEntity entityFrom, TEntity entityTo) => MapEntityKeyValue(orm, typeof(TEntity), entityFrom, entityTo);
|
|
||||||
public static void MapEntityKeyValue(this IFreeSql orm, Type entityType, object entityFrom, object entityTo)
|
public static void MapEntityKeyValue(this IFreeSql orm, Type entityType, object entityFrom, object entityTo)
|
||||||
{
|
{
|
||||||
if (entityType == null) entityType = entityFrom?.GetType() ?? entityTo?.GetType();
|
if (entityType == null) entityType = entityFrom?.GetType() ?? entityTo?.GetType();
|
||||||
@ -354,7 +377,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="entityType"></param>
|
/// <param name="entityType"></param>
|
||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <param name="idtval"></param>
|
/// <param name="idtval"></param>
|
||||||
//public static void SetEntityIdentityValueWithPrimary<TEntity>(this IFreeSql orm, TEntity entity, long idtval) => SetEntityIdentityValueWithPrimary(orm, typeof(TEntity), entity, idtval);
|
|
||||||
public static void SetEntityIdentityValueWithPrimary(this IFreeSql orm, Type entityType, object entity, long idtval)
|
public static void SetEntityIdentityValueWithPrimary(this IFreeSql orm, Type entityType, object entity, long idtval)
|
||||||
{
|
{
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
@ -390,7 +412,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="orm"></param>
|
/// <param name="orm"></param>
|
||||||
/// <param name="entityType"></param>
|
/// <param name="entityType"></param>
|
||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
//public static long GetEntityIdentityValueWithPrimary<TEntity>(this IFreeSql orm, TEntity entity) => GetEntityIdentityValueWithPrimary(orm, typeof(TEntity), entity);
|
|
||||||
public static long GetEntityIdentityValueWithPrimary(this IFreeSql orm, Type entityType, object entity)
|
public static long GetEntityIdentityValueWithPrimary(this IFreeSql orm, Type entityType, object entity)
|
||||||
{
|
{
|
||||||
if (entity == null) return 0;
|
if (entity == null) return 0;
|
||||||
@ -440,7 +461,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="orm"></param>
|
/// <param name="orm"></param>
|
||||||
/// <param name="entityType"></param>
|
/// <param name="entityType"></param>
|
||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
//public static void ClearEntityPrimaryValueWithIdentityAndGuid<TEntity>(this IFreeSql orm, TEntity entity) => ClearEntityPrimaryValueWithIdentityAndGuid(orm, typeof(TEntity), entity);
|
|
||||||
public static void ClearEntityPrimaryValueWithIdentityAndGuid(this IFreeSql orm, Type entityType, object entity)
|
public static void ClearEntityPrimaryValueWithIdentityAndGuid(this IFreeSql orm, Type entityType, object entity)
|
||||||
{
|
{
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
@ -489,7 +509,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="orm"></param>
|
/// <param name="orm"></param>
|
||||||
/// <param name="entityType"></param>
|
/// <param name="entityType"></param>
|
||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
//public static void ClearEntityPrimaryValueWithIdentity<TEntity>(this IFreeSql orm, TEntity entity) => ClearEntityPrimaryValueWithIdentity(orm, typeof(TEntity), entity);
|
|
||||||
public static void ClearEntityPrimaryValueWithIdentity(this IFreeSql orm, Type entityType, object entity)
|
public static void ClearEntityPrimaryValueWithIdentity(this IFreeSql orm, Type entityType, object entity)
|
||||||
{
|
{
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
@ -530,7 +549,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="entity2"></param>
|
/// <param name="entity2"></param>
|
||||||
/// <param name="isEqual"></param>
|
/// <param name="isEqual"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//public static string[] CompareEntityValueReturnColumns<TEntity>(this IFreeSql orm, TEntity entity1, TEntity entity2, bool isEqual) => CompareEntityValueReturnColumns(orm, typeof(TEntity), entity1, entity2, isEqual);
|
|
||||||
public static string[] CompareEntityValueReturnColumns(this IFreeSql orm, Type entityType, object entity1, object entity2, bool isEqual)
|
public static string[] CompareEntityValueReturnColumns(this IFreeSql orm, Type entityType, object entity1, object entity2, bool isEqual)
|
||||||
{
|
{
|
||||||
if (entityType == null) entityType = entity1?.GetType() ?? entity2?.GetType();
|
if (entityType == null) entityType = entity1?.GetType() ?? entity2?.GetType();
|
||||||
@ -598,7 +616,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <param name="propertyName"></param>
|
/// <param name="propertyName"></param>
|
||||||
/// <param name="incrBy"></param>
|
/// <param name="incrBy"></param>
|
||||||
//public static void SetEntityIncrByWithPropertyName<TEntity>(this IFreeSql orm, TEntity entity, string propertyName, int incrBy) => SetEntityIncrByWithPropertyName(orm, typeof(TEntity), entity, propertyName, incrBy);
|
|
||||||
public static void SetEntityIncrByWithPropertyName(this IFreeSql orm, Type entityType, object entity, string propertyName, int incrBy)
|
public static void SetEntityIncrByWithPropertyName(this IFreeSql orm, Type entityType, object entity, string propertyName, int incrBy)
|
||||||
{
|
{
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
@ -643,7 +660,6 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <param name="propertyName"></param>
|
/// <param name="propertyName"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
//public static void SetEntityValueWithPropertyName<TEntity>(this IFreeSql orm, TEntity entity, string propertyName, object value) => SetEntityValueWithPropertyName(orm, typeof(TEntity), entity, propertyName, value);
|
|
||||||
public static void SetEntityValueWithPropertyName(this IFreeSql orm, Type entityType, object entity, string propertyName, object value)
|
public static void SetEntityValueWithPropertyName(this IFreeSql orm, Type entityType, object entity, string propertyName, object value)
|
||||||
{
|
{
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
@ -694,6 +710,53 @@ namespace FreeSql.Extensions.EntityUtil
|
|||||||
});
|
});
|
||||||
func(entity, propertyName, value);
|
func(entity, propertyName, value);
|
||||||
}
|
}
|
||||||
|
public static void SetPropertyValue(this TableInfo table, object entity, string propertyName, object value)
|
||||||
|
{
|
||||||
|
if (table == null || entity == null) return;
|
||||||
|
var func = _dicSetEntityValueWithPropertyName.GetOrAdd(DataType.MsAccess, dt => new ConcurrentDictionary<Type, ConcurrentDictionary<string, Action<object, string, object>>>())
|
||||||
|
.GetOrAdd(table.Type, et => new ConcurrentDictionary<string, Action<object, string, object>>())
|
||||||
|
.GetOrAdd(propertyName, pn =>
|
||||||
|
{
|
||||||
|
var parm1 = Expression.Parameter(typeof(object));
|
||||||
|
var parm2 = Expression.Parameter(typeof(string));
|
||||||
|
var parm3 = Expression.Parameter(typeof(object));
|
||||||
|
var var1Parm = Expression.Variable(table.Type);
|
||||||
|
var exps = new List<Expression>(new Expression[] {
|
||||||
|
Expression.Assign(var1Parm, Expression.TypeAs(parm1, table.Type))
|
||||||
|
});
|
||||||
|
if (table.Properties.ContainsKey(pn))
|
||||||
|
{
|
||||||
|
var prop = table.Properties[pn];
|
||||||
|
|
||||||
|
if (table.ColumnsByCs.ContainsKey(pn))
|
||||||
|
{
|
||||||
|
exps.Add(
|
||||||
|
Expression.Assign(
|
||||||
|
Expression.MakeMemberAccess(var1Parm, prop),
|
||||||
|
Expression.Convert(
|
||||||
|
FreeSql.Internal.Utils.GetDataReaderValueBlockExpression(prop.PropertyType, parm3),
|
||||||
|
prop.PropertyType
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
exps.Add(
|
||||||
|
Expression.Assign(
|
||||||
|
Expression.MakeMemberAccess(var1Parm, prop),
|
||||||
|
Expression.Convert(
|
||||||
|
parm3,
|
||||||
|
prop.PropertyType
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Expression.Lambda<Action<object, string, object>>(Expression.Block(new[] { var1Parm }, exps), new[] { parm1, parm2, parm3 }).Compile();
|
||||||
|
});
|
||||||
|
func(entity, propertyName, value);
|
||||||
|
}
|
||||||
|
|
||||||
static ConcurrentDictionary<Type, MethodInfo[]> _dicAppendEntityUpdateSetWithColumnMethods = new ConcurrentDictionary<Type, MethodInfo[]>();
|
static ConcurrentDictionary<Type, MethodInfo[]> _dicAppendEntityUpdateSetWithColumnMethods = new ConcurrentDictionary<Type, MethodInfo[]>();
|
||||||
static ConcurrentDictionary<Type, ConcurrentDictionary<Type, MethodInfo>> _dicAppendEntityUpdateSetWithColumnMethod = new ConcurrentDictionary<Type, ConcurrentDictionary<Type, MethodInfo>>();
|
static ConcurrentDictionary<Type, ConcurrentDictionary<Type, MethodInfo>> _dicAppendEntityUpdateSetWithColumnMethod = new ConcurrentDictionary<Type, ConcurrentDictionary<Type, MethodInfo>>();
|
||||||
|
@ -3307,6 +3307,26 @@
|
|||||||
总批次数量
|
总批次数量
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:FreeSql.Internal.Model.ColumnInfo.GetDbValue(System.Object)">
|
||||||
|
<summary>
|
||||||
|
获取 obj.CsName 属性值 MapType 之后的数据库值
|
||||||
|
</summary>
|
||||||
|
<param name="obj"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Internal.Model.ColumnInfo.GetValue(System.Object)">
|
||||||
|
<summary>
|
||||||
|
获取 obj.CsName 属性原始值(不经过 MapType)
|
||||||
|
</summary>
|
||||||
|
<param name="obj"></param>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSql.Internal.Model.ColumnInfo.SetValue(System.Object,System.Object)">
|
||||||
|
<summary>
|
||||||
|
设置 obj.CsName 属性值
|
||||||
|
</summary>
|
||||||
|
<param name="obj"></param>
|
||||||
|
<param name="val"></param>
|
||||||
|
</member>
|
||||||
<member name="T:FreeSql.Internal.Model.DynamicFilterInfo">
|
<member name="T:FreeSql.Internal.Model.DynamicFilterInfo">
|
||||||
<summary>
|
<summary>
|
||||||
动态过滤条件
|
动态过滤条件
|
||||||
|
@ -78,12 +78,12 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
if (d == null) continue;
|
if (d == null) continue;
|
||||||
foreach (var col in table.Columns.Values)
|
foreach (var col in table.Columns.Values)
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(d);
|
object val = col.GetValue(d);
|
||||||
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.InsertOrUpdate, col, table.Properties[col.CsName], val);
|
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.InsertOrUpdate, col, table.Properties[col.CsName], val);
|
||||||
orm.Aop.AuditValueHandler(sender, auditArgs);
|
orm.Aop.AuditValueHandler(sender, auditArgs);
|
||||||
if (auditArgs.IsChanged)
|
if (auditArgs.IsChanged)
|
||||||
{
|
{
|
||||||
col.SetMapValue(d, val = auditArgs.Value);
|
col.SetValue(d, val = auditArgs.Value);
|
||||||
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
||||||
changedDict.Add(col.Attribute.Name, true);
|
changedDict.Add(col.Attribute.Name, true);
|
||||||
}
|
}
|
||||||
@ -98,12 +98,12 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。");
|
throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。");
|
||||||
foreach (var col in table.Columns.Values)
|
foreach (var col in table.Columns.Values)
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(data);
|
object val = col.GetValue(data);
|
||||||
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.InsertOrUpdate, col, table.Properties[col.CsName], val);
|
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.InsertOrUpdate, col, table.Properties[col.CsName], val);
|
||||||
orm.Aop.AuditValueHandler(sender, auditArgs);
|
orm.Aop.AuditValueHandler(sender, auditArgs);
|
||||||
if (auditArgs.IsChanged)
|
if (auditArgs.IsChanged)
|
||||||
{
|
{
|
||||||
col.SetMapValue(data, val = auditArgs.Value);
|
col.SetValue(data, val = auditArgs.Value);
|
||||||
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
||||||
changedDict.Add(col.Attribute.Name, true);
|
changedDict.Add(col.Attribute.Name, true);
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
sb.Append(col.DbInsertValue);
|
sb.Append(col.DbInsertValue);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(d);
|
object val = col.GetDbValue(d);
|
||||||
sb.Append(_commonUtils.GetNoneParamaterSqlValue(dbParams, "cu", col.Attribute.MapType, val));
|
sb.Append(_commonUtils.GetNoneParamaterSqlValue(dbParams, "cu", col.Attribute.MapType, val));
|
||||||
}
|
}
|
||||||
if (didx == 0) sb.Append(" as ").Append(col.Attribute.Name);
|
if (didx == 0) sb.Append(" as ").Append(col.Attribute.Name);
|
||||||
|
@ -147,30 +147,28 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。");
|
throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。");
|
||||||
foreach (var col in table.Columns.Values)
|
foreach (var col in table.Columns.Values)
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(data);
|
object val = col.GetValue(data);
|
||||||
if (orm.Aop.AuditValueHandler != null)
|
if (orm.Aop.AuditValueHandler != null)
|
||||||
{
|
{
|
||||||
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.Insert, col, table.Properties[col.CsName], val);
|
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.Insert, col, table.Properties[col.CsName], val);
|
||||||
orm.Aop.AuditValueHandler(sender, auditArgs);
|
orm.Aop.AuditValueHandler(sender, auditArgs);
|
||||||
if (auditArgs.IsChanged)
|
if (auditArgs.IsChanged)
|
||||||
{
|
{
|
||||||
col.SetMapValue(data, val = auditArgs.Value);
|
col.SetValue(data, val = auditArgs.Value);
|
||||||
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
||||||
changedDict.Add(col.Attribute.Name, true);
|
changedDict.Add(col.Attribute.Name, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (col.Attribute.IsPrimary)
|
if (col.Attribute.IsPrimary)
|
||||||
{
|
{
|
||||||
|
val = col.GetDbValue(data);
|
||||||
if (col.Attribute.MapType.NullableTypeOrThis() == typeof(Guid) && (val == null || (Guid)val == Guid.Empty))
|
if (col.Attribute.MapType.NullableTypeOrThis() == typeof(Guid) && (val == null || (Guid)val == Guid.Empty))
|
||||||
col.SetMapValue(data, val = FreeUtil.NewMongodbId());
|
col.SetValue(data, val = FreeUtil.NewMongodbId());
|
||||||
else if (col.CsType.NullableTypeOrThis() == typeof(Guid))
|
else if (col.CsType.NullableTypeOrThis() == typeof(Guid))
|
||||||
{
|
{
|
||||||
var guidVal = orm.GetEntityValueWithPropertyName(table.Type, data, col.CsName);
|
val = col.GetValue(data);
|
||||||
if (guidVal == null || (Guid)guidVal == Guid.Empty)
|
if (val == null || (Guid)val == Guid.Empty)
|
||||||
{
|
col.SetValue(data, val = FreeUtil.NewMongodbId());
|
||||||
orm.SetEntityValueWithPropertyName(table.Type, data, col.CsName, FreeUtil.NewMongodbId());
|
|
||||||
val = col.GetMapValue(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -548,7 +546,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
sb.Append(col.DbInsertValue);
|
sb.Append(col.DbInsertValue);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(d);
|
object val = col.GetDbValue(d);
|
||||||
if (val == null && col.Attribute.IsNullable == false) val = col.CsType == typeof(string) ? "" : Utils.GetDataReaderValue(col.CsType.NullableTypeOrThis(), null);//#384
|
if (val == null && col.Attribute.IsNullable == false) val = col.CsType == typeof(string) ? "" : Utils.GetDataReaderValue(col.CsType.NullableTypeOrThis(), null);//#384
|
||||||
if (_noneParameter)
|
if (_noneParameter)
|
||||||
sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, _noneParameterFlag, col.Attribute.MapType, val));
|
sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, _noneParameterFlag, col.Attribute.MapType, val));
|
||||||
@ -588,7 +586,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
var rowIndex = 0;
|
var rowIndex = 0;
|
||||||
foreach (var col in dtCols)
|
foreach (var col in dtCols)
|
||||||
{
|
{
|
||||||
var val = col.Item1.GetMapValue(d);
|
var val = col.Item1.GetDbValue(d);
|
||||||
if (col.Item3 == true)
|
if (col.Item3 == true)
|
||||||
{
|
{
|
||||||
//if (val == null) throw new Exception($"[{didx}].{col.Item1.CsName} 值不可为 null;DataTable 限制不可使用 int?/long? 可空类型,IInsert.ToDataTable 将映射成 int/long,因此不可接受 null 值");
|
//if (val == null) throw new Exception($"[{didx}].{col.Item1.CsName} 值不可为 null;DataTable 限制不可使用 int?/long? 可空类型,IInsert.ToDataTable 将映射成 int/long,因此不可接受 null 值");
|
||||||
|
@ -350,12 +350,12 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
if (d == null) continue;
|
if (d == null) continue;
|
||||||
foreach (var col in table.Columns.Values)
|
foreach (var col in table.Columns.Values)
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(d);
|
object val = col.GetValue(d);
|
||||||
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.Update, col, table.Properties[col.CsName], val);
|
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.Update, col, table.Properties[col.CsName], val);
|
||||||
orm.Aop.AuditValueHandler(sender, auditArgs);
|
orm.Aop.AuditValueHandler(sender, auditArgs);
|
||||||
if (auditArgs.IsChanged)
|
if (auditArgs.IsChanged)
|
||||||
{
|
{
|
||||||
col.SetMapValue(d, val = auditArgs.Value);
|
col.SetValue(d, val = auditArgs.Value);
|
||||||
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
||||||
changedDict.Add(col.Attribute.Name, true);
|
changedDict.Add(col.Attribute.Name, true);
|
||||||
}
|
}
|
||||||
@ -370,12 +370,12 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。");
|
throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。");
|
||||||
foreach (var col in table.Columns.Values)
|
foreach (var col in table.Columns.Values)
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(data);
|
object val = col.GetValue(data);
|
||||||
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.Update, col, table.Properties[col.CsName], val);
|
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.Update, col, table.Properties[col.CsName], val);
|
||||||
orm.Aop.AuditValueHandler(sender, auditArgs);
|
orm.Aop.AuditValueHandler(sender, auditArgs);
|
||||||
if (auditArgs.IsChanged)
|
if (auditArgs.IsChanged)
|
||||||
{
|
{
|
||||||
col.SetMapValue(data, val = auditArgs.Value);
|
col.SetValue(data, val = auditArgs.Value);
|
||||||
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
||||||
changedDict.Add(col.Attribute.Name, true);
|
changedDict.Add(col.Attribute.Name, true);
|
||||||
}
|
}
|
||||||
@ -403,18 +403,18 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
|
|
||||||
protected void SetPriv(ColumnInfo col, object value)
|
protected void SetPriv(ColumnInfo col, object value)
|
||||||
{
|
{
|
||||||
object paramVal = null;
|
object val = null;
|
||||||
if (col.Attribute.MapType == col.CsType) paramVal = value;
|
if (col.Attribute.MapType == col.CsType) val = value;
|
||||||
else paramVal = Utils.GetDataReaderValue(col.Attribute.MapType, value);
|
else val = Utils.GetDataReaderValue(col.Attribute.MapType, value);
|
||||||
_set.Append(", ").Append(_commonUtils.QuoteSqlName(col.Attribute.Name)).Append(" = ");
|
_set.Append(", ").Append(_commonUtils.QuoteSqlName(col.Attribute.Name)).Append(" = ");
|
||||||
if (_noneParameter)
|
if (_noneParameter)
|
||||||
{
|
{
|
||||||
_set.Append(_commonUtils.GetNoneParamaterSqlValue(_params, "u", col.Attribute.MapType, paramVal));
|
_set.Append(_commonUtils.GetNoneParamaterSqlValue(_params, "u", col.Attribute.MapType, val));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_set.Append(_commonUtils.QuoteWriteParamter(col.Attribute.MapType, $"{_commonUtils.QuoteParamterName("p_")}{_params.Count}"));
|
_set.Append(_commonUtils.QuoteWriteParamter(col.Attribute.MapType, $"{_commonUtils.QuoteParamterName("p_")}{_params.Count}"));
|
||||||
_commonUtils.AppendParamter(_params, null, col, col.Attribute.MapType, paramVal);
|
_commonUtils.AppendParamter(_params, null, col, col.Attribute.MapType, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IUpdate<T1> Set<TMember>(Expression<Func<T1, TMember>> column, TMember value)
|
public IUpdate<T1> Set<TMember>(Expression<Func<T1, TMember>> column, TMember value)
|
||||||
@ -565,7 +565,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
sb.Append(_commonUtils.QuoteSqlName(col.Attribute.Name)).Append(" = ");
|
sb.Append(_commonUtils.QuoteSqlName(col.Attribute.Name)).Append(" = ");
|
||||||
sb.Append(thenValue(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "u", col.Attribute.MapType, col.GetMapValue(_source.First()))));
|
sb.Append(thenValue(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "u", col.Attribute.MapType, col.GetDbValue(_source.First()))));
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
|
|
||||||
@ -588,7 +588,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
cwsb.Append(" \r\nWHEN ");
|
cwsb.Append(" \r\nWHEN ");
|
||||||
ToSqlWhen(cwsb, _table.Primarys, d);
|
ToSqlWhen(cwsb, _table.Primarys, d);
|
||||||
cwsb.Append(" THEN ");
|
cwsb.Append(" THEN ");
|
||||||
var val = col.GetMapValue(d);
|
var val = col.GetDbValue(d);
|
||||||
cwsb.Append(thenValue(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "u", col.Attribute.MapType, val)));
|
cwsb.Append(thenValue(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "u", col.Attribute.MapType, val)));
|
||||||
if (val == null || val == DBNull.Value) nulls++;
|
if (val == null || val == DBNull.Value) nulls++;
|
||||||
}
|
}
|
||||||
@ -660,7 +660,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
sb.Append(col.DbUpdateValue);
|
sb.Append(col.DbUpdateValue);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var val = col.GetMapValue(_source.First());
|
var val = col.GetDbValue(_source.First());
|
||||||
if (_noneParameter)
|
if (_noneParameter)
|
||||||
sb.Append(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "u", col.Attribute.MapType, val));
|
sb.Append(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "u", col.Attribute.MapType, val));
|
||||||
else
|
else
|
||||||
@ -705,7 +705,7 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
cwsb.Append(" \r\nWHEN ");
|
cwsb.Append(" \r\nWHEN ");
|
||||||
ToSqlWhen(cwsb, _table.Primarys, d);
|
ToSqlWhen(cwsb, _table.Primarys, d);
|
||||||
cwsb.Append(" THEN ");
|
cwsb.Append(" THEN ");
|
||||||
var val = col.GetMapValue(d);
|
var val = col.GetDbValue(d);
|
||||||
if (_noneParameter)
|
if (_noneParameter)
|
||||||
cwsb.Append(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "u", col.Attribute.MapType, val));
|
cwsb.Append(_commonUtils.GetNoneParamaterSqlValue(_paramsSource, "u", col.Attribute.MapType, val));
|
||||||
else
|
else
|
||||||
|
@ -277,7 +277,7 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" AND ");
|
if (pkidx > 0) sb.Append(" AND ");
|
||||||
sb.Append(aliasAndDot).Append(this.QuoteSqlName(pk.Attribute.Name));
|
sb.Append(aliasAndDot).Append(this.QuoteSqlName(pk.Attribute.Name));
|
||||||
sb.Append(this.FormatSql(" = {0}", pk.GetMapValue(dywhere)));
|
sb.Append(this.FormatSql(" = {0}", pk.GetDbValue(dywhere)));
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
@ -301,7 +301,7 @@ namespace FreeSql.Internal
|
|||||||
var itype = i.GetType();
|
var itype = i.GetType();
|
||||||
isEntityType = (itype == table.Type || itype.BaseType == table.Type);
|
isEntityType = (itype == table.Type || itype.BaseType == table.Type);
|
||||||
}
|
}
|
||||||
if (isEntityType) sb.Append(this.FormatSql("{0}", primarys[0].GetMapValue(i)));
|
if (isEntityType) sb.Append(this.FormatSql("{0}", primarys[0].GetDbValue(i)));
|
||||||
else sb.Append(this.FormatSql("{0}", Utils.GetDataReaderValue(pk1.Attribute.MapType, i)));
|
else sb.Append(this.FormatSql("{0}", Utils.GetDataReaderValue(pk1.Attribute.MapType, i)));
|
||||||
++ieidx;
|
++ieidx;
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
var sbin = new StringBuilder();
|
var sbin = new StringBuilder();
|
||||||
sbin.Append(aliasAndDot).Append(this.QuoteSqlName(pk1.Attribute.Name));
|
sbin.Append(aliasAndDot).Append(this.QuoteSqlName(pk1.Attribute.Name));
|
||||||
var indt = its.Select(a => pk1.GetMapValue(a)).Where(a => a != null).ToArray();
|
var indt = its.Select(a => pk1.GetDbValue(a)).Where(a => a != null).ToArray();
|
||||||
if (indt.Any() == false) return null;
|
if (indt.Any() == false) return null;
|
||||||
if (indt.Length == 1) sbin.Append(" = ").Append(this.FormatSql("{0}", indt.First()));
|
if (indt.Length == 1) sbin.Append(" = ").Append(this.FormatSql("{0}", indt.First()));
|
||||||
else sbin.Append(" IN (").Append(string.Join(",", indt.Select(a => this.FormatSql("{0}", a)))).Append(")");
|
else sbin.Append(" IN (").Append(string.Join(",", indt.Select(a => this.FormatSql("{0}", a)))).Append(")");
|
||||||
@ -365,7 +365,7 @@ namespace FreeSql.Internal
|
|||||||
{
|
{
|
||||||
var filter = "";
|
var filter = "";
|
||||||
foreach (var pk in table.Primarys)
|
foreach (var pk in table.Primarys)
|
||||||
filter += $" AND {aliasAndDot}{this.QuoteSqlName(pk.Attribute.Name)} = {this.FormatSql("{0}", pk.GetMapValue(item))}";
|
filter += $" AND {aliasAndDot}{this.QuoteSqlName(pk.Attribute.Name)} = {this.FormatSql("{0}", pk.GetDbValue(item))}";
|
||||||
if (string.IsNullOrEmpty(filter)) continue;
|
if (string.IsNullOrEmpty(filter)) continue;
|
||||||
if (sb != null)
|
if (sb != null)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
|
using FreeSql.Extensions.EntityUtil;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -20,8 +21,37 @@ namespace FreeSql.Internal.Model
|
|||||||
public int DbSize { get; internal set; }
|
public int DbSize { get; internal set; }
|
||||||
public byte DbPrecision { get; internal set; }
|
public byte DbPrecision { get; internal set; }
|
||||||
public byte DbScale { get; internal set; }
|
public byte DbScale { get; internal set; }
|
||||||
|
//public Func<object, object> ConversionCsToDb { get; internal set; }
|
||||||
|
//public Func<object, object> ConversionDbToCs { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取 obj.CsName 属性值 MapType 之后的数据库值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public object GetDbValue(object obj)
|
||||||
|
{
|
||||||
|
var dbval = Table.GetPropertyValue(obj, CsName);
|
||||||
|
//if (ConversionCsToDb != null) dbval = ConversionCsToDb(dbval);
|
||||||
|
if (Attribute.MapType != CsType) dbval = Utils.GetDataReaderValue(Attribute.MapType, dbval);
|
||||||
|
return dbval;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取 obj.CsName 属性原始值(不经过 MapType)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj"></param>
|
||||||
|
public object GetValue(object obj) => Table.GetPropertyValue(obj, CsName);
|
||||||
|
/// <summary>
|
||||||
|
/// 设置 obj.CsName 属性值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj"></param>
|
||||||
|
/// <param name="val"></param>
|
||||||
|
public void SetValue(object obj, object val) => Table.SetPropertyValue(obj, CsName, Utils.GetDataReaderValue(CsType, val));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static ConcurrentDictionary<ColumnInfo, Func<object, object>> _dicGetMapValue = new ConcurrentDictionary<ColumnInfo, Func<object, object>>();
|
static ConcurrentDictionary<ColumnInfo, Func<object, object>> _dicGetMapValue = new ConcurrentDictionary<ColumnInfo, Func<object, object>>();
|
||||||
|
[Obsolete("请使用 GetDbValue 或者 GetValue")]
|
||||||
public object GetMapValue(object obj)
|
public object GetMapValue(object obj)
|
||||||
{
|
{
|
||||||
var func = _dicGetMapValue.GetOrAdd(this, col =>
|
var func = _dicGetMapValue.GetOrAdd(this, col =>
|
||||||
@ -57,6 +87,7 @@ namespace FreeSql.Internal.Model
|
|||||||
return func(obj);
|
return func(obj);
|
||||||
}
|
}
|
||||||
static ConcurrentDictionary<ColumnInfo, Action<object, object>> _dicSetMapValue = new ConcurrentDictionary<ColumnInfo, Action<object, object>>();
|
static ConcurrentDictionary<ColumnInfo, Action<object, object>> _dicSetMapValue = new ConcurrentDictionary<ColumnInfo, Action<object, object>>();
|
||||||
|
[Obsolete("请使用 SetValue")]
|
||||||
public void SetMapValue(object obj, object val)
|
public void SetMapValue(object obj, object val)
|
||||||
{
|
{
|
||||||
var func = _dicSetMapValue.GetOrAdd(this, col =>
|
var func = _dicSetMapValue.GetOrAdd(this, col =>
|
||||||
|
@ -66,7 +66,7 @@ namespace FreeSql.Dameng.Curd
|
|||||||
sb.Append(col.DbInsertValue);
|
sb.Append(col.DbInsertValue);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(d);
|
object val = col.GetDbValue(d);
|
||||||
if (val == null && col.Attribute.IsNullable == false) val = col.CsType == typeof(string) ? "" : Utils.GetDataReaderValue(col.CsType.NullableTypeOrThis(), null);//#384
|
if (val == null && col.Attribute.IsNullable == false) val = col.CsType == typeof(string) ? "" : Utils.GetDataReaderValue(col.CsType.NullableTypeOrThis(), null);//#384
|
||||||
if (_noneParameter)
|
if (_noneParameter)
|
||||||
sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, _noneParameterFlag, col.Attribute.MapType, val));
|
sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, _noneParameterFlag, col.Attribute.MapType, val));
|
||||||
|
@ -49,7 +49,7 @@ namespace FreeSql.Dameng.Curd
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("(");
|
sb.Append("(");
|
||||||
@ -57,7 +57,7 @@ namespace FreeSql.Dameng.Curd
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" || '+' || ");
|
if (pkidx > 0) sb.Append(" || '+' || ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d)));
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -54,14 +54,14 @@ namespace FreeSql.MsAccess.Curd
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var pkidx = 0;
|
var pkidx = 0;
|
||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" + '+' + ");
|
if (pkidx > 0) sb.Append(" + '+' + ");
|
||||||
sb.Append(MsAccessUtils.GetCastSql(_commonUtils.FormatSql("{0}", pk.GetMapValue(d)), typeof(string)));
|
sb.Append(MsAccessUtils.GetCastSql(_commonUtils.FormatSql("{0}", pk.GetDbValue(d)), typeof(string)));
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ namespace FreeSql.MySql.Curd
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("CONCAT(");
|
sb.Append("CONCAT(");
|
||||||
@ -98,7 +98,7 @@ namespace FreeSql.MySql.Curd
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(", '+', ");
|
if (pkidx > 0) sb.Append(", '+', ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d)));
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -66,7 +66,7 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
sb.Append(col.DbInsertValue);
|
sb.Append(col.DbInsertValue);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(d);
|
object val = col.GetDbValue(d);
|
||||||
if (val == null && col.Attribute.IsNullable == false) val = col.CsType == typeof(string) ? "" : Utils.GetDataReaderValue(col.CsType.NullableTypeOrThis(), null);//#384
|
if (val == null && col.Attribute.IsNullable == false) val = col.CsType == typeof(string) ? "" : Utils.GetDataReaderValue(col.CsType.NullableTypeOrThis(), null);//#384
|
||||||
if (_noneParameter)
|
if (_noneParameter)
|
||||||
sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, _noneParameterFlag, col.Attribute.MapType, val));
|
sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, _noneParameterFlag, col.Attribute.MapType, val));
|
||||||
|
@ -50,7 +50,7 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("(");
|
sb.Append("(");
|
||||||
@ -58,7 +58,7 @@ namespace FreeSql.Odbc.Dameng
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" || '+' || ");
|
if (pkidx > 0) sb.Append(" || '+' || ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d)));
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -47,14 +47,14 @@ namespace FreeSql.Odbc.Default
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var pkidx = 0;
|
var pkidx = 0;
|
||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" + '+' + ");
|
if (pkidx > 0) sb.Append(" + '+' + ");
|
||||||
sb.Append(_utils.Adapter.CastSql(_commonUtils.FormatSql("{0}", pk.GetMapValue(d)), _utils.Adapter.MappingOdbcTypeVarChar));
|
sb.Append(_utils.Adapter.CastSql(_commonUtils.FormatSql("{0}", pk.GetDbValue(d)), _utils.Adapter.MappingOdbcTypeVarChar));
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ namespace FreeSql.Odbc.KingbaseES
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("(");
|
sb.Append("(");
|
||||||
@ -101,7 +101,7 @@ namespace FreeSql.Odbc.KingbaseES
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" || '+' || ");
|
if (pkidx > 0) sb.Append(" || '+' || ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d))).Append("::text");
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append("::text");
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -90,7 +90,7 @@ namespace FreeSql.Odbc.MySql
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("CONCAT(");
|
sb.Append("CONCAT(");
|
||||||
@ -98,7 +98,7 @@ namespace FreeSql.Odbc.MySql
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(", '+', ");
|
if (pkidx > 0) sb.Append(", '+', ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d)));
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -66,7 +66,7 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
sb.Append(col.DbInsertValue);
|
sb.Append(col.DbInsertValue);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(d);
|
object val = col.GetDbValue(d);
|
||||||
if (val == null && col.Attribute.IsNullable == false) val = col.CsType == typeof(string) ? "" : Utils.GetDataReaderValue(col.CsType.NullableTypeOrThis(), null);//#384
|
if (val == null && col.Attribute.IsNullable == false) val = col.CsType == typeof(string) ? "" : Utils.GetDataReaderValue(col.CsType.NullableTypeOrThis(), null);//#384
|
||||||
if (_noneParameter)
|
if (_noneParameter)
|
||||||
sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, _noneParameterFlag, col.Attribute.MapType, val));
|
sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, _noneParameterFlag, col.Attribute.MapType, val));
|
||||||
|
@ -52,7 +52,7 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
{
|
{
|
||||||
if (_table.Primarys[0].Attribute.DbType.Contains("NVARCHAR2"))
|
if (_table.Primarys[0].Attribute.DbType.Contains("NVARCHAR2"))
|
||||||
sb.Append("N");
|
sb.Append("N");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("(");
|
sb.Append("(");
|
||||||
@ -60,7 +60,7 @@ namespace FreeSql.Odbc.Oracle
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" || '+' || ");
|
if (pkidx > 0) sb.Append(" || '+' || ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d)));
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -93,7 +93,7 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("(");
|
sb.Append("(");
|
||||||
@ -101,7 +101,7 @@ namespace FreeSql.Odbc.PostgreSQL
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" || '+' || ");
|
if (pkidx > 0) sb.Append(" || '+' || ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d))).Append("::text");
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append("::text");
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -88,14 +88,14 @@ namespace FreeSql.Odbc.SqlServer
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var pkidx = 0;
|
var pkidx = 0;
|
||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" + '+' + ");
|
if (pkidx > 0) sb.Append(" + '+' + ");
|
||||||
sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d))).Append(" as varchar)");
|
sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)");
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ namespace FreeSql.Oracle.Curd
|
|||||||
sb.Append(col.DbInsertValue);
|
sb.Append(col.DbInsertValue);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(d);
|
object val = col.GetDbValue(d);
|
||||||
if (val == null && col.Attribute.IsNullable == false) val = col.CsType == typeof(string) ? "" : Utils.GetDataReaderValue(col.CsType.NullableTypeOrThis(), null);//#384
|
if (val == null && col.Attribute.IsNullable == false) val = col.CsType == typeof(string) ? "" : Utils.GetDataReaderValue(col.CsType.NullableTypeOrThis(), null);//#384
|
||||||
if (_noneParameter)
|
if (_noneParameter)
|
||||||
sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, _noneParameterFlag, col.Attribute.MapType, val));
|
sb.Append(_commonUtils.GetNoneParamaterSqlValue(specialParams, _noneParameterFlag, col.Attribute.MapType, val));
|
||||||
|
@ -52,7 +52,7 @@ namespace FreeSql.Oracle.Curd
|
|||||||
{
|
{
|
||||||
if (_table.Primarys[0].Attribute.DbType.Contains("NVARCHAR2"))
|
if (_table.Primarys[0].Attribute.DbType.Contains("NVARCHAR2"))
|
||||||
sb.Append("N");
|
sb.Append("N");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("(");
|
sb.Append("(");
|
||||||
@ -60,7 +60,7 @@ namespace FreeSql.Oracle.Curd
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" || '+' || ");
|
if (pkidx > 0) sb.Append(" || '+' || ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d)));
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -93,7 +93,7 @@ namespace FreeSql.PostgreSQL.Curd
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("(");
|
sb.Append("(");
|
||||||
@ -101,7 +101,7 @@ namespace FreeSql.PostgreSQL.Curd
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" || '+' || ");
|
if (pkidx > 0) sb.Append(" || '+' || ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d))).Append("::text");
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append("::text");
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -94,7 +94,7 @@ namespace FreeSql.ShenTong.Curd
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("(");
|
sb.Append("(");
|
||||||
@ -102,7 +102,7 @@ namespace FreeSql.ShenTong.Curd
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" || '+' || ");
|
if (pkidx > 0) sb.Append(" || '+' || ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d))).Append("::text");
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append("::text");
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -89,14 +89,14 @@ namespace FreeSql.SqlServer.Curd
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var pkidx = 0;
|
var pkidx = 0;
|
||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" + '+' + ");
|
if (pkidx > 0) sb.Append(" + '+' + ");
|
||||||
sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d))).Append(" as varchar)");
|
sb.Append("cast(").Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d))).Append(" as varchar)");
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace FreeSql.Sqlite.Curd
|
|||||||
{
|
{
|
||||||
if (_table.Primarys.Length == 1)
|
if (_table.Primarys.Length == 1)
|
||||||
{
|
{
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys.First().GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", _table.Primarys[0].GetDbValue(d)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sb.Append("(");
|
sb.Append("(");
|
||||||
@ -58,7 +58,7 @@ namespace FreeSql.Sqlite.Curd
|
|||||||
foreach (var pk in _table.Primarys)
|
foreach (var pk in _table.Primarys)
|
||||||
{
|
{
|
||||||
if (pkidx > 0) sb.Append(" || '+' || ");
|
if (pkidx > 0) sb.Append(" || '+' || ");
|
||||||
sb.Append(_commonUtils.FormatSql("{0}", pk.GetMapValue(d)));
|
sb.Append(_commonUtils.FormatSql("{0}", pk.GetDbValue(d)));
|
||||||
++pkidx;
|
++pkidx;
|
||||||
}
|
}
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
@ -188,7 +188,7 @@ QQ群:4336577(已满)、8578575(在线)
|
|||||||
## 💕 Donation
|
## 💕 Donation
|
||||||
|
|
||||||
L*y 58元、花花 88元、麦兜很乖 50元、网络来者 2000元、John 99.99元、alex 666元、bacongao 36元、无名 100元、Eternity 188元、无名 10元、⌒.Helper~..oO 66元、习惯与被习惯 100元、无名 100元、蔡易喋 88.88元、中讯科技 1000元、Good Good Work 24元、炽焰 6.6元、Nothing 100元、兰州天擎赵 500元、哈利路亚 300元、
|
L*y 58元、花花 88元、麦兜很乖 50元、网络来者 2000元、John 99.99元、alex 666元、bacongao 36元、无名 100元、Eternity 188元、无名 10元、⌒.Helper~..oO 66元、习惯与被习惯 100元、无名 100元、蔡易喋 88.88元、中讯科技 1000元、Good Good Work 24元、炽焰 6.6元、Nothing 100元、兰州天擎赵 500元、哈利路亚 300元、
|
||||||
无名 100元、无名 99.99元
|
无名 100元、蛰伏 99.99元
|
||||||
|
|
||||||
> Thank you for your donation
|
> Thank you for your donation
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user