Browse Source

Insert update add dictionary Or dynamic Overloading of functions

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
e7a061b052
  1. 36
      Src/Asp.Net/SqlSugar/SqlSugarClient.cs

36
Src/Asp.Net/SqlSugar/SqlSugarClient.cs

@ -261,6 +261,24 @@ namespace SqlSugar
{
return this.Insertable(new T[] { insertObj });
}
public virtual IInsertable<T> Insertable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
{
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Insertable.columnDictionary can't be null");
var insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(columnDictionary));
return this.Insertable(insertObject);
}
public virtual IInsertable<T> Insertable<T>(dynamic insertDynamicObject) where T : class, new()
{
if (insertDynamicObject is T)
{
return this.Insertable((T)insertDynamicObject);
}
else
{
var insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(insertDynamicObject));
return this.Insertable(insertObject);
}
}
#endregion
#region Deleteable
@ -316,6 +334,24 @@ namespace SqlSugar
{
return this.Updateable(new T[] { new T() });
}
public virtual IUpdateable<T> Updateable<T>(Dictionary<string, object> columnDictionary) where T : class, new()
{
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Updateable.columnDictionary can't be null");
var updateObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(columnDictionary));
return this.Updateable(updateObject);
}
public virtual IUpdateable<T> Updateable<T>(dynamic updateDynamicObject) where T : class, new()
{
if (updateDynamicObject is T)
{
return this.Updateable((T)updateDynamicObject);
}
else
{
var updateObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(updateDynamicObject));
return this.Updateable(updateObject);
}
}
#endregion
#region DbFirst

Loading…
Cancel
Save