예제 #1
0
        private BInfo DataRowToEntity(DataRow row)
        {
            BInfo info = new BInfo();

            info.ID    = Convert.ToInt32(row["ID"]);
            info.Value = Convert.ToInt32(row["Value"]);

            return(info);
        }
예제 #2
0
        public BInfo FindByID(object id)
        {
            BInfo  result = null;
            string sql    = @"SELECT ID,Value
                            FROM B
                            WHERE ID=@id";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("id", id),
            };
            DataTable table = SqlHelper.ExecuteDataset(sql, param).Tables[0];

            if (table != null && table.Rows.Count > 0)
            {
                result = DataRowToEntity(table.Rows[0]);
            }

            return(result);
        }
예제 #3
0
        public int Insert(BInfo model, SqlTransaction trans = null)
        {
            string sql = @"INSERT INTO B
                        (ID,Value)
                        VALUES (@ID,@Value)";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("ID", model.ID),
                new SqlParameter("Value", model.Value),
            };
            if (trans == null)
            {
                SqlHelper.ExecuteScalar(sql, param);
            }
            else
            {
                SqlHelper.ExecuteScalar(trans, sql, param);
            }
            return(model.ID);
        }
예제 #4
0
        public int Update(BInfo model, SqlTransaction trans = null)
        {
            string sql = @"UPDATE B
                            SET Value=@Value
                            WHERE ID=@ID";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("ID", model.ID),
                new SqlParameter("Value", model.Value),
            };

            if (trans == null)
            {
                return(SqlHelper.ExecuteNonQuery(sql, param));
            }
            else
            {
                return(SqlHelper.ExecuteNonQuery(trans, sql, param));
            }
        }