public int Delete <T>(object keyValue) where T : class { DynamicParameters dynamicParameters = new global::Dapper.DynamicParameters(); dynamicParameters.Add("@primarykey", keyValue); return(ExecuteBySql("Delete " + EntityAttribute.GetEntityTable <T>() + " where " + EntityAttribute.GetEntityKey <T>() + "=@primarykey", dynamicParameters)); }
public int Delete <T>(object[] keyValue) where T : class { DynamicParameters dynamicParameters = new global::Dapper.DynamicParameters(); string whereString = string.Empty; string keyString = EntityAttribute.GetEntityKey <T>(); for (int i = 0; i < keyValue.Length; i++) { string ParametersName = string.Format("@primarykey{0}", i); dynamicParameters.Add(ParametersName, keyValue[i]); whereString += string.Format("{0} {1} = {2}", i == 0 ? string.Empty : " OR ", keyString, ParametersName); } string deleteString = "Delete " + EntityAttribute.GetEntityTable <T>() + " where "; ExecuteBySql(string.Format("{0}{1}", deleteString, whereString), dynamicParameters); return(dbTransaction == null?Commit() : 0); }