public long Insert <TEntity>(TEntity entity) where TEntity : class { SetCommonAddProperty(new object[] { entity }); string sql = SQLBuilder.BuildAddSql <TEntity>(MyContext.GetTableName(typeof(TEntity)), entity).ToString(); long id = Convert.ToInt64((ExecuteScalar(sql).ToString())); ReflectionUtil.SetPropertyValue(entity, "id", id); return(id); }
public int InsertNoId <TEntity>(IEnumerable <TEntity> entitys) where TEntity : class { if (entitys == null || entitys.Count() <= 0) { return(0); } SetCommonAddProperty(entitys.ToArray()); string sql = SQLBuilder.BuildAddSql <TEntity>(MyContext.GetTableName(typeof(TEntity)), entitys).ToString(); return(ExecuteNonQuery(sql)); }