public bool InsertAsync(Copys model) { using (var conn = DapperFactory.GetConnection()) { var fields = model.ToFields(); if (fields == null || fields.Count == 0) { return(false); } string sql = string.Format("insert into [Copys] ({0}) values ({1});", string.Join(",", fields), string.Join(",", fields.Select(n => "@" + n))); return(conn.Execute(sql, model) > 0); } }
public bool UpdateAsync(Copys model) { using (var conn = DapperFactory.GetConnection()) { var fields = model.ToFields(); if (fields == null || fields.Count == 0) { return(false); } var fieldList = new List <string>(); foreach (var field in fields) { fieldList.Add(string.Format("{0}=@{0}", field)); } string sql = string.Format("update [Copys] set {0};", string.Join(",", fieldList)); return(conn.Execute(sql, model) > 0); } }