mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-26 18:59:17 +08:00
4.6.1
This commit is contained in:
@@ -15,8 +15,10 @@ namespace OrmTest.Demo
|
|||||||
Name = "attr"
|
Name = "attr"
|
||||||
};
|
};
|
||||||
db.Insertable(a).AS("student").ExecuteCommand();
|
db.Insertable(a).AS("student").ExecuteCommand();
|
||||||
|
var list = db.Queryable<AttributeTest>().AS("student").ToList();
|
||||||
var list = db.Queryable<AttributeTest>().AS("student").Select(it => new AttributeTest() { Aid = it.Aid + 1,CreateTime=DateTime.Now,Name=it.Name }).ToList();
|
var list2 = db.Queryable<AttributeTest>().AS("student").Select(it => new AttributeTest() { Aid = it.Aid + 1,CreateTime=DateTime.Now,Name=it.Name }).ToList();
|
||||||
|
var s = new AttributeTest2() { Aid = 1,AName="a", CreateTime=DateTime.Now };
|
||||||
|
var count = db.Updateable(s).UpdateColumns(it=>new { it.CreateTime,it.AName }).Where(it=>it.Aid==100).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AttributeTest
|
public class AttributeTest
|
||||||
@@ -27,5 +29,15 @@ namespace OrmTest.Demo
|
|||||||
[SugarColumn(IsOnlyIgnoreInsert = true)]
|
[SugarColumn(IsOnlyIgnoreInsert = true)]
|
||||||
public DateTime CreateTime { get; set; }
|
public DateTime CreateTime { get; set; }
|
||||||
}
|
}
|
||||||
|
[SugarTable("student")]
|
||||||
|
public class AttributeTest2
|
||||||
|
{
|
||||||
|
[SugarColumn(ColumnName = "Id")]
|
||||||
|
public int Aid { get; set; }
|
||||||
|
[SugarColumn(ColumnName = "Name")]
|
||||||
|
public string AName { get; set; }
|
||||||
|
[SugarColumn(IsOnlyIgnoreInsert = true)]
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,6 +219,15 @@ namespace SqlSugar
|
|||||||
return !currentIgnoreColumns.Any(i => it.PropertyName.Equals(i.PropertyName, StringComparison.CurrentCulture));
|
return !currentIgnoreColumns.Any(i => it.PropertyName.Equals(i.PropertyName, StringComparison.CurrentCulture));
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.Context.IgnoreInsertColumns != null && this.Context.IgnoreInsertColumns.Any())
|
||||||
|
{
|
||||||
|
var currentIgnoreColumns = this.Context.IgnoreInsertColumns.Where(it => it.EntityName == this.EntityInfo.EntityName).ToList();
|
||||||
|
this.InsertBuilder.DbColumnInfoList = this.InsertBuilder.DbColumnInfoList.Where(it =>
|
||||||
|
{
|
||||||
|
return !currentIgnoreColumns.Any(i => it.PropertyName.Equals(i.PropertyName, StringComparison.CurrentCulture));
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
if (this.IsSingle)
|
if (this.IsSingle)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ namespace SqlSugar
|
|||||||
item.IsPrimarykey = true;
|
item.IsPrimarykey = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => updateColumns.Any(uc => uc.Equals(it.PropertyName, StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey || it.IsIdentity).ToList();
|
this.UpdateBuilder.DbColumnInfoList = this.UpdateBuilder.DbColumnInfoList.Where(it => updateColumns.Any(uc => uc.Equals(it.PropertyName, StringComparison.CurrentCultureIgnoreCase) || uc.Equals(it.DbColumnName, StringComparison.CurrentCultureIgnoreCase)) || it.IsPrimarykey || it.IsIdentity).ToList();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,13 @@ namespace SqlSugar
|
|||||||
base._Parameters = new List<SugarParameter>();
|
base._Parameters = new List<SugarParameter>();
|
||||||
}
|
}
|
||||||
public ExpressionContext GetCopyContext()
|
public ExpressionContext GetCopyContext()
|
||||||
|
{
|
||||||
|
ExpressionContext copyContext = (ExpressionContext)Activator.CreateInstance(this.GetType(), true);
|
||||||
|
copyContext.Index = this.Index;
|
||||||
|
copyContext.ParameterIndex = this.ParameterIndex;
|
||||||
|
return copyContext;
|
||||||
|
}
|
||||||
|
public ExpressionContext GetCopyContextWithMapping()
|
||||||
{
|
{
|
||||||
ExpressionContext copyContext = (ExpressionContext)Activator.CreateInstance(this.GetType(), true);
|
ExpressionContext copyContext = (ExpressionContext)Activator.CreateInstance(this.GetType(), true);
|
||||||
copyContext.Index = this.Index;
|
copyContext.Index = this.Index;
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (this.Context.Result.IsLockCurrentParameter == false)
|
if (this.Context.Result.IsLockCurrentParameter == false)
|
||||||
{
|
{
|
||||||
var newContext = this.Context.GetCopyContext();
|
var newContext = this.Context.GetCopyContextWithMapping();
|
||||||
var resolveExpressType = this.Context.IsSingle ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple;
|
var resolveExpressType = this.Context.IsSingle ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple;
|
||||||
newContext.Resolve(item, resolveExpressType);
|
newContext.Resolve(item, resolveExpressType);
|
||||||
this.Context.Index = newContext.Index;
|
this.Context.Index = newContext.Index;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace SqlSugar
|
|||||||
public MappingTableList MappingTables = new MappingTableList();
|
public MappingTableList MappingTables = new MappingTableList();
|
||||||
public MappingColumnList MappingColumns = new MappingColumnList();
|
public MappingColumnList MappingColumns = new MappingColumnList();
|
||||||
public IgnoreColumnList IgnoreColumns = new IgnoreColumnList();
|
public IgnoreColumnList IgnoreColumns = new IgnoreColumnList();
|
||||||
|
public IgnoreColumnList IgnoreInsertColumns = new IgnoreColumnList();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
@@ -146,6 +147,8 @@ namespace SqlSugar
|
|||||||
this.Context.MappingColumns = new MappingColumnList();
|
this.Context.MappingColumns = new MappingColumnList();
|
||||||
if (this.Context.IgnoreColumns == null)
|
if (this.Context.IgnoreColumns == null)
|
||||||
this.Context.IgnoreColumns = new IgnoreColumnList();
|
this.Context.IgnoreColumns = new IgnoreColumnList();
|
||||||
|
if (this.Context.IgnoreInsertColumns == null)
|
||||||
|
this.Context.IgnoreInsertColumns = new IgnoreColumnList();
|
||||||
if (!this.Context.MappingTables.Any(it => it.EntityName == entityInfo.EntityName))
|
if (!this.Context.MappingTables.Any(it => it.EntityName == entityInfo.EntityName))
|
||||||
{
|
{
|
||||||
if (entityInfo.DbTableName != entityInfo.EntityName && entityInfo.DbTableName.HasValue())
|
if (entityInfo.DbTableName != entityInfo.EntityName && entityInfo.DbTableName.HasValue())
|
||||||
@@ -163,11 +166,18 @@ namespace SqlSugar
|
|||||||
this.Context.MappingColumns.Add(item.PropertyName, item.DbColumnName, item.EntityName);
|
this.Context.MappingColumns.Add(item.PropertyName, item.DbColumnName, item.EntityName);
|
||||||
}
|
}
|
||||||
var ignoreInfos = this.Context.IgnoreColumns.Where(it => it.EntityName == entityInfo.EntityName);
|
var ignoreInfos = this.Context.IgnoreColumns.Where(it => it.EntityName == entityInfo.EntityName);
|
||||||
foreach (var item in entityInfo.Columns.Where(it => it.IsIgnore||it.IsOnlyIgnoreInsert))
|
foreach (var item in entityInfo.Columns.Where(it => it.IsIgnore))
|
||||||
{
|
{
|
||||||
if (!ignoreInfos.Any(it => it.PropertyName == item.PropertyName))
|
if (!ignoreInfos.Any(it => it.PropertyName == item.PropertyName))
|
||||||
this.Context.IgnoreColumns.Add(item.PropertyName, item.EntityName);
|
this.Context.IgnoreColumns.Add(item.PropertyName, item.EntityName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ignoreInsertInfos = this.Context.IgnoreInsertColumns.Where(it => it.EntityName == entityInfo.EntityName);
|
||||||
|
foreach (var item in entityInfo.Columns.Where(it => it.IsOnlyIgnoreInsert))
|
||||||
|
{
|
||||||
|
if (!ignoreInsertInfos.Any(it => it.PropertyName == item.PropertyName))
|
||||||
|
this.Context.IgnoreInsertColumns.Add(item.PropertyName, item.EntityName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("4.6.0.9")]
|
[assembly: AssemblyVersion("4.6.1")]
|
||||||
[assembly: AssemblyFileVersion("4.6.0.9")]
|
[assembly: AssemblyFileVersion("4.6.1")]
|
||||||
|
|||||||
Reference in New Issue
Block a user