public void Insert(T model) { string sql = ORMUtil.ConstructInsertStatement(model.GetType()); var objs = GetStatementParamArray(model); SQLExecutor.ExecuteNonQuery(sql, _connectionString, objs.ToArray()); }
protected void DeleteByKey(IDictionary <string, object> conditions) { StringBuilder sb = new StringBuilder(); sb.Append(ORMUtil.ConstructDeleteStatement(typeof(T))); sb.Append(ConstructWhereByDictionary(conditions)); SQLExecutor.ExecuteNonQuery(sb.ToString(), _connectionString, conditions.Values.ToArray()); }
public void Update(T model) { string sql = ORMUtil.ConstructUpdateStatement(model.GetType()); var objs = GetAllParamArrays(model); SQLExecutor.ExecuteNonQuery(sql, _connectionString, objs.ToArray()); }
protected IList <T> ReadByKey(IDictionary <string, object> conditions) { StringBuilder sb = new StringBuilder(); sb.Append(ORMUtil.ConstructSelectStatement(typeof(T))); sb.Append(ConstructWhereByDictionary(conditions)); return(ORMUtil.ConvertDataTableToModel <T>(SQLExecutor.GetDataTable(sb.ToString(), _connectionString, conditions.Values.ToArray()))); }
private void button1_Click(object sender, EventArgs e) { try { string tableName = this.txtTable.Text.Trim(); string sql = $"SELECT * FROM {tableName}"; ORMUtil.GenerateClass(ConfigurationManager.AppSettings["ConnectionString"], sql); string directoryPath = $"{Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName}"; MessageBox.Show(this, "Both model and data access service classes have been generated."); Process.Start(directoryPath); this.Close(); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); MessageBox.Show(this, "Table name does not exist."); } }
public IList <T> ReadAll() { var table = SQLExecutor.GetDataTable(ORMUtil.ConstructSelectStatement(typeof(T)), _connectionString); return(ORMUtil.ConvertDataTableToModel <T>(table)); }