private StringBuilder Build() { var columnList = new List <string>(); var parameterList = new List <string>(); var type = typeof(T); var(tableName, properties) = Utility.ProviderHelper.GetMetas(type); foreach (var p in properties) { if (p.IsIdentity) { continue; } columnList.Add(p.ColumnName); parameterList.Add($"{DbPrefix}{p.Parameter}"); SqlParameter.Add(p.Parameter, p.PropertyInfo.GetValue(_model)); //Console.WriteLine("Name:{0} Value:{1}", p.Name, p.GetValue(_model)); } StringBuilder sql = new StringBuilder(); sql.Append($"insert into {tableName} ({string.Join(",", columnList)}) values ({string.Join(",", parameterList)})"); return(sql); }
public void AddParameter(string sqlParameter, SqlDbType sqlDbType, string value) { if (sqlParameter != string.Empty && value != string.Empty) { SqlParameter.Add(sqlParameter); SqlParameterType.Add(sqlDbType); SqlParameterValue.Add(value); NrOfParameters++; HasParameters = true; } }