示例#1
0
        public void Insert(T model)
        {
            string sql  = ORMUtil.ConstructInsertStatement(model.GetType());
            var    objs = GetStatementParamArray(model);

            SQLExecutor.ExecuteNonQuery(sql, _connectionString, objs.ToArray());
        }
示例#2
0
        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());
        }
示例#3
0
        public void Update(T model)
        {
            string sql = ORMUtil.ConstructUpdateStatement(model.GetType());

            var objs = GetAllParamArrays(model);

            SQLExecutor.ExecuteNonQuery(sql, _connectionString, objs.ToArray());
        }
示例#4
0
        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())));
        }
示例#5
0
        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.");
            }
        }
示例#6
0
        public IList <T> ReadAll()
        {
            var table = SQLExecutor.GetDataTable(ORMUtil.ConstructSelectStatement(typeof(T)), _connectionString);

            return(ORMUtil.ConvertDataTableToModel <T>(table));
        }