public int Update(TEntity entity) { //UPDATE Customers SET Col1=@Col1,Col2=@Col2,Col3=@Col3; var props = _type.GetProperties(); List <SqlParameter> sqlParameters = new List <SqlParameter>(); foreach (var prop in props) { sqlParameters.Add(new SqlParameter($"@{prop.Name}", SqlHelperBase.ToDbValue(prop.GetValue(entity)))); } return(_sqlHelperW.ExecuteNoQuery(_updateText, sqlParameters.ToArray())); }
public object InsertBackRecord(TEntity entity) { //INSERT INTO Customers {col1,col2,clo3} VALUES(@Col1,@Col2,@Col3); var props = _type.GetProperties().Where(m => !m.Name.Equals("Id")); //var strCols = GetColumns().Where(m => !m.Equals("Id")); List <SqlParameter> sqlParameters = new List <SqlParameter>(); foreach (var prop in props) { sqlParameters.Add(new SqlParameter($"@{prop.Name}", SqlHelperBase.ToDbValue(prop.GetValue(entity)))); } return(_sqlHelperW.ExecuteScalar(_insertBackText, sqlParameters.ToArray())); }
public int Insert(TEntity entity) { //INSERT INTO Customers {col1,col2,clo3} VALUES(@Col1,@Col2,@Col3); IEnumerable <PropertyInfo> props = _type.GetProperties().Where(m => !m.Name.Equals("Id")); //IEnumerable<string> strCols = GetColumns().Where(m => !m.Equals("Id")); List <SqlParameter> sqlParameters = new List <SqlParameter>(); foreach (var prop in props) { sqlParameters.Add(new SqlParameter($"@{prop.Name}", SqlHelperBase.ToDbValue(prop.GetValue(entity)))); } return(_sqlHelperW.ExecuteNoQuery(_insertText, sqlParameters.ToArray())); }