예제 #1
0
파일: itemDAO.cs 프로젝트: nEdAy/Graduation
///<summary>
///查询单个模型实体
///</summary>
///<param name=objectId>主键</param>);
///<returns>实体</returns>);
        public Dictionary <string, object> QuerySingleByIdX(string objectId, object columns)
        {
            Dictionary <string, string[]> li;

            string[] clumns = new String[] { "objectId", "title", "price", "discount", "details", "type", "mall_name", "label", "hot", "love", "reward", "pic_a", "pic_b", "pic_c", "url", "commentCount", "state", "admin", "updatedAt", "createdAt" };
            string[] cls    = columns.parseColumnsX(clumns, "item", out li);
            string   sql    = "SELECT TOP 1 " + string.Join(",", li["item"]) + " from item WHERE [objectId] = @objectId";

            using (var reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@objectId", objectId)))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    Dictionary <string, object> model = SqlHelper.MapEntity(reader, cls);
                    if (li.ContainsKey("_User"))
                    {
                        _UserDAO _UserDAO = new _UserDAO();
                        model["_User"] = _UserDAO.QuerySingleByIdX((string)reader["_UserId"], li["_User"]);
                    }

                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #2
0
파일: itemDAO.cs 프로젝트: nEdAy/Graduation
///<summary>
///分页查询一个集合
///</summary>
///<param name="index">页码</param>
///<param name="size">页大小</param>
///<param name="columns">指定的列</param>
///<param name="wheres">条件匿名类</param>
///<param name="orderField">排序字段</param>
///<param name="isDesc">是否降序排序</param>
///<returns>实体集合</returns>
        public IEnumerable <Dictionary <string, object> > QueryListX(int index, int size, object columns = null, object wheres = null, string orderField = "objectId", bool isDesc = true)
        {
            List <SqlParameter> list = null;

            string where = wheres.parseWheres(out list);
            orderField   = string.IsNullOrEmpty(orderField) ? "objectId" : orderField;
            Dictionary <string, string[]> li;

            string[] clumns = new String[] { "objectId", "title", "price", "discount", "details", "type", "mall_name", "label", "hot", "love", "reward", "pic_a", "pic_b", "pic_c", "url", "commentCount", "state", "admin", "updatedAt", "createdAt" };
            string[] cls    = columns.parseColumnsX(clumns, "item", out li);
            var      sql    = SqlHelper.GenerateQuerySql("item", li["item"], index, size, where, orderField, isDesc);

            using (var reader = SqlHelper.ExecuteReader(sql, list.ToArray()))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Dictionary <string, object> model = SqlHelper.MapEntity(reader, cls);
                        if (li.ContainsKey("_User"))
                        {
                            _UserDAO _UserDAO = new _UserDAO();
                            model["_User"] = _UserDAO.QuerySingleByIdX((string)reader["_UserId"], li["_User"]);
                        }

                        yield return(model);
                    }
                }
            }
        }
예제 #3
0
파일: itemDAO.cs 프로젝트: nEdAy/Graduation
///<summary>
///查询单个模型实体
///</summary>
///<param name="wheres">条件</param>
///<param name="columns">列集合</param>
///<returns>实体</returns>
        public Dictionary <string, object> QuerySingleByWheresX(object wheres, object columns)
        {
            List <SqlParameter> list = null;

            string where = wheres.parseWheres(out list);
            where        = string.IsNullOrEmpty(where) ? "" : " where " + where;
            Dictionary <string, string[]> li;

            string[] clumns = new String[] { "objectId", "title", "price", "discount", "details", "type", "mall_name", "label", "hot", "love", "reward", "pic_a", "pic_b", "pic_c", "url", "commentCount", "state", "admin", "updatedAt", "createdAt" };
            string[] cls    = columns.parseColumnsX(clumns, "item", out li);
            string   sql    = "SELECT TOP 1 " + string.Join(",", li["item"]) + " from item" + where;

            using (var reader = SqlHelper.ExecuteReader(sql, list.ToArray()))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    Dictionary <string, object> model = SqlHelper.MapEntity(reader, cls);
                    if (li.ContainsKey("_User"))
                    {
                        _UserDAO _UserDAO = new _UserDAO();
                        model["_User"] = _UserDAO.QuerySingleByIdX((string)reader["_UserId"], li["_User"]);
                    }

                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #4
0
///<summary>
///查询单个模型实体
///</summary>
///<param name="wheres">条件</param>
///<param name="columns">列集合</param>
///<returns>实体</returns>
        public Dictionary <string, object> QuerySingleByWheresX(object wheres, object columns)
        {
            List <SqlParameter> list = null;

            string where = wheres.parseWheres(out list);
            where        = string.IsNullOrEmpty(where) ? "" : " where " + where;
            Dictionary <string, string[]> li;

            string[] clumns = new String[] { "objectId", "parentId", "contents", "replyCount", "updatedAt", "createdAt" };
            string[] cls    = columns.parseColumnsX(clumns, "Comment", out li);
            string   sql    = "SELECT TOP 1 " + string.Join(",", li["Comment"]) + " from Comment" + where;

            using (var reader = SqlHelper.ExecuteReader(sql, list.ToArray()))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    Dictionary <string, object> model = SqlHelper.MapEntity(reader, cls);
                    if (li.ContainsKey("_User"))
                    {
                        _UserDAO _UserDAO = new _UserDAO();
                        model["_User"] = _UserDAO.QuerySingleByIdX((string)reader["_UserId"], li["_User"]);
                    }

                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #5
0
///<summary>
///查询单个模型实体
///</summary>
///<param name=objectId>主键</param>);
///<returns>实体</returns>);
        public Dictionary <string, object> QuerySingleByIdX(string objectId, object columns)
        {
            Dictionary <string, string[]> li;

            string[] clumns = new String[] { "objectId", "parentId", "contents", "replyCount", "updatedAt", "createdAt" };
            string[] cls    = columns.parseColumnsX(clumns, "Comment", out li);
            string   sql    = "SELECT TOP 1 " + string.Join(",", li["Comment"]) + " from Comment WHERE [objectId] = @objectId";

            using (var reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@objectId", objectId)))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    Dictionary <string, object> model = SqlHelper.MapEntity(reader, cls);
                    if (li.ContainsKey("_User"))
                    {
                        _UserDAO _UserDAO = new _UserDAO();
                        model["_User"] = _UserDAO.QuerySingleByIdX((string)reader["_UserId"], li["_User"]);
                    }

                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #6
0
///<summary>
///分页查询一个集合
///</summary>
///<param name="index">页码</param>
///<param name="size">页大小</param>
///<param name="columns">指定的列</param>
///<param name="wheres">条件匿名类</param>
///<param name="orderField">排序字段</param>
///<param name="isDesc">是否降序排序</param>
///<returns>实体集合</returns>
        public IEnumerable <Dictionary <string, object> > QueryListX(int index, int size, object columns = null, object wheres = null, string orderField = "objectId", bool isDesc = true)
        {
            List <SqlParameter> list = null;

            string where = wheres.parseWheres(out list);
            orderField   = string.IsNullOrEmpty(orderField) ? "objectId" : orderField;
            Dictionary <string, string[]> li;

            string[] clumns = new String[] { "objectId", "updatedAt", "createdAt", "toldId", "msg" };
            string[] cls    = columns.parseColumnsX(clumns, "Message", out li);
            var      sql    = SqlHelper.GenerateQuerySql("Message", li["Message"], index, size, where, orderField, isDesc);

            using (var reader = SqlHelper.ExecuteReader(sql, list.ToArray()))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Dictionary <string, object> model = SqlHelper.MapEntity(reader, cls);
                        if (li.ContainsKey("_User"))
                        {
                            _UserDAO _UserDAO = new _UserDAO();
                            model["_User"] = _UserDAO.QuerySingleByIdX((string)reader["_UserID"], li["_User"]);
                        }

                        yield return(model);
                    }
                }
            }
        }
예제 #7
0
파일: itemDAO.cs 프로젝트: nEdAy/Graduation
/// <summary>
/// 查询单个模型实体
/// </summary>
/// <param name="id">objectId</param>);
/// <returns>实体</returns>);
        public item QuerySingleById(string objectId)
        {
            const string sql = "SELECT TOP 1 objectId,_UserId,title,price,discount,details,type,mall_name,label,hot,love,reward,pic_a,pic_b,pic_c,url,commentCount,state,admin,updatedAt,createdAt from item WHERE [objectId] = @objectId";

            using (var reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@objectId", objectId)))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    item     model    = SqlHelper.MapEntity <item>(reader);
                    _UserDAO _UserDAO = new _UserDAO();
                    model._User = _UserDAO.QuerySingleById((string)reader["_UserId"]);
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #8
0
/// <summary>
/// 查询单个模型实体
/// </summary>
/// <param name="id">objectId</param>);
/// <returns>实体</returns>);
        public Comment QuerySingleById(string objectId)
        {
            const string sql = "SELECT TOP 1 objectId,parentId,contents,replyCount,_UserId,updatedAt,createdAt from Comment WHERE [objectId] = @objectId";

            using (var reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@objectId", objectId)))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    Comment  model    = SqlHelper.MapEntity <Comment>(reader);
                    _UserDAO _UserDAO = new _UserDAO();
                    model._User = _UserDAO.QuerySingleById((string)reader["_UserId"]);
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #9
0
/// <summary>
/// 查询单个模型实体
/// </summary>
/// <param name="id">objectId</param>);
/// <returns>实体</returns>);
        public Message QuerySingleById(string objectId)
        {
            const string sql = "SELECT TOP 1 objectId,updatedAt,createdAt,_UserID,toldId,msg from Message WHERE [objectId] = @objectId";

            using (var reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@objectId", objectId)))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    Message  model    = SqlHelper.MapEntity <Message>(reader);
                    _UserDAO _UserDAO = new _UserDAO();
                    model._User = _UserDAO.QuerySingleById((string)reader["_UserID"]);
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
예제 #10
0
파일: itemDAO.cs 프로젝트: nEdAy/Graduation
///<summary>
///分页查询一个集合
///</summary>
///<param name="index">页码</param>
///<param name="size">页大小</param>
///<param name="wheres">条件匿名类</param>
///<param name="orderField">排序字段</param>
///<param name="isDesc">是否降序排序</param>
///<returns>实体集合</returns>
        public IEnumerable <item> QueryList(int index, int size, object wheres = null, string orderField = "objectId", bool isDesc = true)
        {
            List <SqlParameter> list = null;

            string where = wheres.parseWheres(out list);
            orderField   = string.IsNullOrEmpty(orderField) ? "objectId" : orderField;
            var sql = SqlHelper.GenerateQuerySql("item", new string[] { "objectId", "_UserId", "title", "price", "discount", "details", "type", "mall_name", "label", "hot", "love", "reward", "pic_a", "pic_b", "pic_c", "url", "commentCount", "state", "admin", "updatedAt", "createdAt" }, index, size, where, orderField, isDesc);

            using (var reader = SqlHelper.ExecuteReader(sql, list.ToArray()))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        item     model    = SqlHelper.MapEntity <item>(reader);
                        _UserDAO _UserDAO = new _UserDAO();
                        model._User = _UserDAO.QuerySingleById((string)reader["_UserId"]);
                        yield return(model);
                    }
                }
            }
        }
예제 #11
0
///<summary>
///分页查询一个集合
///</summary>
///<param name="index">页码</param>
///<param name="size">页大小</param>
///<param name="wheres">条件匿名类</param>
///<param name="orderField">排序字段</param>
///<param name="isDesc">是否降序排序</param>
///<returns>实体集合</returns>
        public IEnumerable <Comment> QueryList(int index, int size, object wheres = null, string orderField = "objectId", bool isDesc = true)
        {
            List <SqlParameter> list = null;

            string where = wheres.parseWheres(out list);
            orderField   = string.IsNullOrEmpty(orderField) ? "objectId" : orderField;
            var sql = SqlHelper.GenerateQuerySql("Comment", new string[] { "objectId", "parentId", "contents", "replyCount", "_UserId", "updatedAt", "createdAt" }, index, size, where, orderField, isDesc);

            using (var reader = SqlHelper.ExecuteReader(sql, list.ToArray()))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Comment  model    = SqlHelper.MapEntity <Comment>(reader);
                        _UserDAO _UserDAO = new _UserDAO();
                        model._User = _UserDAO.QuerySingleById((string)reader["_UserId"]);
                        yield return(model);
                    }
                }
            }
        }
예제 #12
0
/// <summary>
/// 查询单个模型实体
/// </summary>
/// <param name="id">objectId</param>);
/// <returns>实体</returns>);
        public ItemUser QuerySingleById(string objectId)
        {
            const string sql = "SELECT TOP 1 objectId,itemId,_UserId,love,dislove,fav,updatedAt,createdAt from ItemUser WHERE [objectId] = @objectId";

            using (var reader = SqlHelper.ExecuteReader(sql, new SqlParameter("@objectId", objectId)))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    ItemUser model    = SqlHelper.MapEntity <ItemUser>(reader);
                    _UserDAO _UserDAO = new _UserDAO();
                    model._User = _UserDAO.QuerySingleById((string)reader["_UserId"]);
                    itemDAO itemDAO = new itemDAO();
                    model.item = itemDAO.QuerySingleById((string)reader["itemId"]);
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }