当前位置: 首页>>代码示例>>C#>>正文


C# IConnection.ExecuteReader方法代码示例

本文整理汇总了C#中IConnection.ExecuteReader方法的典型用法代码示例。如果您正苦于以下问题:C# IConnection.ExecuteReader方法的具体用法?C# IConnection.ExecuteReader怎么用?C# IConnection.ExecuteReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IConnection的用法示例。


在下文中一共展示了IConnection.ExecuteReader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAllGiftListGroups

        public IList<GiftListGroupEntity> GetAllGiftListGroups(IConnection conn)
        {
            List<GiftListGroupEntity> giftListGrouplist = new List<GiftListGroupEntity>();
            string sql = "SELECT giftListGroupId, giftListFK, groupFK, updateTimestamp, updatePersonFK FROM DBO.GIFTLIST;";

            var rdr = conn.ExecuteReader(sql);
            while (rdr.Read())
            {
                var giftListGroup = new GiftListGroupEntity()
                {
                    giftListGroupId = rdr.IsDBNull(rdr.GetOrdinal("giftListGroupId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("giftListGroupId")),
                    giftListFK = rdr.IsDBNull(rdr.GetOrdinal("giftListFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("giftListFK")),
                    groupFK = rdr.IsDBNull(rdr.GetOrdinal("groupFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("groupFK")),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                giftListGrouplist.Add(giftListGroup);
            }

            return giftListGrouplist;
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:21,代码来源:GiftListGroupRepository.cs

示例2: GetAllPurchases

        public IList<PurchaseEntity> GetAllPurchases(IConnection conn)
        {
            List<PurchaseEntity> purchaseList = new List<PurchaseEntity>();
            string sql = "SELECT purchaseId, itemFK, purchaserFK, purchaseDate, updateTimestamp, updatePersonKey FROM DBO.PURCHASE;";

            var rdr = conn.ExecuteReader(sql);
            while (rdr.Read())
            {
                var purchase = new PurchaseEntity()
                {
                    purchaseId = rdr.IsDBNull(rdr.GetOrdinal("purchaseId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("purchaseId")),
                    itemFK = rdr.IsDBNull(rdr.GetOrdinal("itemFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemFK")),
                    purchaserFK = rdr.IsDBNull(rdr.GetOrdinal("purchaserFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("purchaserFK")),
                    purchaseDate = rdr.IsDBNull(rdr.GetOrdinal("purchaseDate")) ? null : (DateTime?)rdr.GetDateTime(rdr.GetOrdinal("purchaseDate")),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                purchaseList.Add(purchase);
            }
            return purchaseList;
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:21,代码来源:PurchaseRepository.cs

示例3: GetAllPersons

        public IList<PersonEntity> GetAllPersons(IConnection conn)
        {
            List<PersonEntity> personList = new List<PersonEntity>();

            string sql = "SELECT personId, userName, emailAddress, firstName, lastName, passwordHash FROM DBO.PERSON;";

            var rdr = conn.ExecuteReader(sql);
            while (rdr.Read())
            {
                var person = new PersonEntity()
                {
                    personId = rdr.IsDBNull(rdr.GetOrdinal("personId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("personId")),
                    userName = rdr.IsDBNull(rdr.GetOrdinal("userName")) ? null : rdr.GetString(rdr.GetOrdinal("userName")),
                    emailAddress = rdr.IsDBNull(rdr.GetOrdinal("emailAddress")) ? null : rdr.GetString(rdr.GetOrdinal("emailAddress")),
                    firstName = rdr.IsDBNull(rdr.GetOrdinal("firstName")) ? null : rdr.GetString(rdr.GetOrdinal("firstName")),
                    lastName = rdr.IsDBNull(rdr.GetOrdinal("lastName")) ? null : rdr.GetString(rdr.GetOrdinal("lastName")),
                    passwordHash = rdr.IsDBNull(rdr.GetOrdinal("passwordHash")) ? null : rdr.GetString(rdr.GetOrdinal("passwordHash"))
                };
                personList.Add(person);
            }
            return personList;
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:22,代码来源:PersonRepository.cs

示例4: GetAllGroups

        public IList<GroupEntity> GetAllGroups(IConnection conn)
        {
            List<GroupEntity> groupList = new List<GroupEntity>();
            string sql = "SELECT groupId, creatorFK, groupName, description, isPrivate, updateTimestamp, updatePersonFK FROM dbo.[group];";

            var rdr = conn.ExecuteReader(sql);
            while (rdr.Read())
            {
                var group = new GroupEntity()
                {
                    groupId = rdr.IsDBNull(rdr.GetOrdinal("linkId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("linkId")),
                    creatorFK = rdr.IsDBNull(rdr.GetOrdinal("itemFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemFK")),
                    groupName = rdr.IsDBNull(rdr.GetOrdinal("linkName")) ? null : rdr.GetString(rdr.GetOrdinal("linkName")),
                    description = rdr.IsDBNull(rdr.GetOrdinal("url")) ? null : rdr.GetString(rdr.GetOrdinal("url")),
                    isPrivate = rdr.IsDBNull(rdr.GetOrdinal("isImage")) ? false : (rdr.GetString(rdr.GetOrdinal("isImage")) == "Y"),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonKey")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonKey"))
                };
                groupList.Add(group);
            }

            return groupList;
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:23,代码来源:GroupRepository.cs

示例5: GetAllItemComments

        public IList<ItemCommentEntity> GetAllItemComments(IConnection conn)
        {
            List<ItemCommentEntity> itemCommentList = new List<ItemCommentEntity>();

            string sql = "SELECT itemCommentId, itemFK, commentorFK, commentText, isHiddenFromOwner, updateTimestamp, updatePersonFK FROM dbo.itemComment;";

            var rdr = conn.ExecuteReader(sql);
            while (rdr.Read())
            {
                var itemComment = new ItemCommentEntity()
                {
                    itemCommentId = rdr.IsDBNull(rdr.GetOrdinal("itemCommentId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemCommentId")),
                    itemFK = rdr.IsDBNull(rdr.GetOrdinal("itemFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemFK")),
                    commentorFK = rdr.IsDBNull(rdr.GetOrdinal("commentorFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("commentorFK")),
                    commentText = rdr.IsDBNull(rdr.GetOrdinal("commentText")) ? null : rdr.GetString(rdr.GetOrdinal("commentText")),
                    isHiddenFromOwner = rdr.IsDBNull(rdr.GetOrdinal("isHiddenFromOwner")) ? true : (rdr.GetString(rdr.GetOrdinal("isHiddenFromOwner")) == "Y"),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                itemCommentList.Add(itemComment);
            }
            return itemCommentList;
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:23,代码来源:ItemCommentRepository.cs

示例6: GetAllGroupMembers

        public IList<GroupMemberEntity> GetAllGroupMembers(IConnection conn)
        {
            List<GroupMemberEntity> groupMemberList = new List<GroupMemberEntity>();

            string sql = "SELECT groupMemberId, groupFK, memberFK, isAdmin, updateTimestamp, updatePersonFK FROM DBO.GROUPMEMBER;";

            var rdr = conn.ExecuteReader(sql);
            while (rdr.Read())
            {
                var groupMember = new GroupMemberEntity()
                {
                    groupMemberId = rdr.IsDBNull(rdr.GetOrdinal("groupMemberId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("groupMemberId")),
                    groupFK = rdr.IsDBNull(rdr.GetOrdinal("groupFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("groupFK")),
                    memberFK = rdr.IsDBNull(rdr.GetOrdinal("memberFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("memberFK")),
                    isAdmin = rdr.IsDBNull(rdr.GetOrdinal("isAdmin")) ? false : (rdr.GetString(rdr.GetOrdinal("isAdmin")) == "Y"),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                groupMemberList.Add(groupMember);
            }

            return groupMemberList;
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:23,代码来源:GroupMemberRepository.cs

示例7: GetAllLinks

        public IList<LinkEntity> GetAllLinks(IConnection conn)
        {
            List<LinkEntity> linklist = new List<LinkEntity>();

            string sql = "SELECT linkId, itemFK, linkName, url, isImage, updateTimestamp, updatePersonFK FROM DBO.LINK;";

            var rdr = conn.ExecuteReader(sql);
            while (rdr.Read())
            {
                var link = new LinkEntity()
                {
                    linkId = rdr.IsDBNull(rdr.GetOrdinal("linkId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("linkId")),
                    itemFK = rdr.IsDBNull(rdr.GetOrdinal("itemFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemFK")),
                    linkName = rdr.IsDBNull(rdr.GetOrdinal("linkName")) ? null : rdr.GetString(rdr.GetOrdinal("linkName")),
                    url = rdr.IsDBNull(rdr.GetOrdinal("url")) ? null : rdr.GetString(rdr.GetOrdinal("url")),
                    isImage = rdr.IsDBNull(rdr.GetOrdinal("isImage")) ? false : (rdr.GetString(rdr.GetOrdinal("isImage")) == "Y"),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                linklist.Add(link);
            }
            return linklist;
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:23,代码来源:LinkRepository.cs

示例8: GetAllGiftLists

        public IList<GiftListEntity> GetAllGiftLists(IConnection conn)
        {
            List<GiftListEntity> giftListlist = new List<GiftListEntity>();

            string sql = "SELECT giftListId, personFK, listName, isPrivate, updateTimestamp, updatePersonFK FROM DBO.GIFTLIST;";
            List<SqlParameter> prms = new List<SqlParameter>();

            var rdr = conn.ExecuteReader(sql,prms);
            while (rdr.Read())
            {
                var giftList = new GiftListEntity()
                {
                    giftListId = rdr.IsDBNull(rdr.GetOrdinal("giftListId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("giftListId")),
                    personFK = rdr.IsDBNull(rdr.GetOrdinal("personFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("personFK")),
                    listName = rdr.IsDBNull(rdr.GetOrdinal("listName")) ? null : rdr.GetString(rdr.GetOrdinal("listName")),
                    isPrivate = rdr.IsDBNull(rdr.GetOrdinal("isPrivate")) ? false : (rdr.GetString(rdr.GetOrdinal("isPrivate")) == "Y"),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                giftListlist.Add(giftList);
            }

            return giftListlist;
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:24,代码来源:GiftListRepository.cs

示例9: GetAllItems

        public IList<ItemEntity> GetAllItems(IConnection conn)
        {
            List<ItemEntity> itemList = new List<ItemEntity>();

            string sql = "SELECT itemId, itemStatusFK, giftListFK, itemName, description, updateTimestamp, updatePersonFK FROM dbo.item;";

            var rdr = conn.ExecuteReader(sql);
            while (rdr.Read())
            {
                var item = new ItemEntity()
                {
                    itemId = rdr.IsDBNull(rdr.GetOrdinal("itemId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemId")),
                    itemStatusFK = rdr.IsDBNull(rdr.GetOrdinal("itemStatusFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemStatusFK")),
                    giftListFK = rdr.IsDBNull(rdr.GetOrdinal("giftListFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("giftListFK")),
                    itemName = rdr.IsDBNull(rdr.GetOrdinal("itemName")) ? null : rdr.GetString(rdr.GetOrdinal("itemName")),
                    description = rdr.IsDBNull(rdr.GetOrdinal("description")) ? null : rdr.GetString(rdr.GetOrdinal("description")),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                itemList.Add(item);
            }

            return itemList;
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:24,代码来源:ItemRepository.cs

示例10: GetAllPersonsLike

        public IList<PersonEntity> GetAllPersonsLike(string partialUserName, IConnection conn)
        {
            List<PersonEntity> personList = new List<PersonEntity>();

            string sql = "SELECT personId, userName, emailAddress, firstName, lastName, passwordHash FROM DBO.PERSON WHERE userName like @partialUserName;";
            List<SqlParameter> prms = new List<SqlParameter>();
            prms.Add(new SqlParameter { ParameterName = "@partialUserName", Value = "%" + partialUserName + "%" });

            var rdr = conn.ExecuteReader(sql,prms);
            while (rdr.Read())
            {
                var person = new PersonEntity()
                {
                    personId = rdr.IsDBNull(rdr.GetOrdinal("personId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("personId")),
                    userName = rdr.IsDBNull(rdr.GetOrdinal("userName")) ? null : rdr.GetString(rdr.GetOrdinal("userName")),
                    emailAddress = rdr.IsDBNull(rdr.GetOrdinal("emailAddress")) ? null : rdr.GetString(rdr.GetOrdinal("emailAddress")),
                    firstName = rdr.IsDBNull(rdr.GetOrdinal("firstName")) ? null : rdr.GetString(rdr.GetOrdinal("firstName")),
                    lastName = rdr.IsDBNull(rdr.GetOrdinal("lastName")) ? null : rdr.GetString(rdr.GetOrdinal("lastName")),
                    passwordHash = rdr.IsDBNull(rdr.GetOrdinal("passwordHash")) ? null : rdr.GetString(rdr.GetOrdinal("passwordHash"))
                };
                personList.Add(person);
            }
            return personList;
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:24,代码来源:PersonRepository.cs

示例11: GetGiftListGroupById

        public GiftListGroupEntity GetGiftListGroupById(int id, IConnection conn)
        {
            List<GiftListGroupEntity> giftListGrouplist = new List<GiftListGroupEntity>();

            string sql = "SELECT giftListGroupId, giftListFK, groupFK, updateTimestamp, updatePersonFK FROM DBO.GIFTLIST WHERE giftListGroupId = @id;";
            List<SqlParameter> prms = new List<SqlParameter>();

            var paramId = new SqlParameter
            {
                ParameterName = "@id",
                Value = id
            };
            prms.Add(paramId);

            var rdr = conn.ExecuteReader(sql,prms);
            while (rdr.Read())
            {
                var giftListGroup = new GiftListGroupEntity()
                {
                    giftListGroupId = rdr.IsDBNull(rdr.GetOrdinal("giftListGroupId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("giftListGroupId")),
                    giftListFK = rdr.IsDBNull(rdr.GetOrdinal("giftListFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("giftListFK")),
                    groupFK = rdr.IsDBNull(rdr.GetOrdinal("groupFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("groupFK")),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                giftListGrouplist.Add(giftListGroup);
            }

            return giftListGrouplist.FirstOrDefault();
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:30,代码来源:GiftListGroupRepository.cs

示例12: GetLinkById

        public LinkEntity GetLinkById(int id, IConnection conn)
        {
            List<LinkEntity> linklist = new List<LinkEntity>();

            string sql = "SELECT linkId, itemFK, url, linkName, isImage, updateTimestamp, updatePersonFK FROM DBO.LINK WHERE linkId = @id";
            List<SqlParameter> prms = new List<SqlParameter>();
            prms.Add(new SqlParameter { ParameterName = "@id", Value = id });

            var rdr = conn.ExecuteReader(sql,prms);
            while (rdr.Read())
            {
                var link = new LinkEntity()
                {
                    linkId = rdr.IsDBNull(rdr.GetOrdinal("linkId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("linkId")),
                    itemFK = rdr.IsDBNull(rdr.GetOrdinal("itemFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemFK")),
                    linkName = rdr.IsDBNull(rdr.GetOrdinal("linkName")) ? null : rdr.GetString(rdr.GetOrdinal("linkName")),
                    url = rdr.IsDBNull(rdr.GetOrdinal("url")) ? null : rdr.GetString(rdr.GetOrdinal("url")),
                    isImage = rdr.IsDBNull(rdr.GetOrdinal("isImage")) ? false : rdr.GetBoolean(rdr.GetOrdinal("isImage")),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                linklist.Add(link);
            }
            return linklist.FirstOrDefault();
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:25,代码来源:LinkRepository.cs

示例13: GetGroupById

        public GroupEntity GetGroupById(int id, IConnection conn)
        {
            List<GroupEntity> grouplist = new List<GroupEntity>();

            string sql = "SELECT groupId, creatorFK, groupName, description, isPrivate, updateTimestamp, updatePersonFK FROM dbo.[group] WHERE groupId = @id;";
            List<SqlParameter> prms = new List<SqlParameter>();

            var paramName = new SqlParameter
            {
                ParameterName = "@id",
                Value = id
            };
            prms.Add(paramName);

            var rdr = conn.ExecuteReader(sql,prms);
            while (rdr.Read())
            {
                var group = new GroupEntity()
                {
                    groupId = rdr.IsDBNull(rdr.GetOrdinal("linkId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("linkId")),
                    creatorFK = rdr.IsDBNull(rdr.GetOrdinal("itemFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemFK")),
                    groupName = rdr.IsDBNull(rdr.GetOrdinal("linkName")) ? null : rdr.GetString(rdr.GetOrdinal("linkName")),
                    description = rdr.IsDBNull(rdr.GetOrdinal("url")) ? null : rdr.GetString(rdr.GetOrdinal("url")),
                    isPrivate = rdr.IsDBNull(rdr.GetOrdinal("isImage")) ? false : (rdr.GetString(rdr.GetOrdinal("isImage")) == "Y"),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonKey")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonKey"))
                };
                grouplist.Add(group);
            }

            return grouplist.FirstOrDefault();
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:32,代码来源:GroupRepository.cs

示例14: GetItemCommentByItem

        public ItemCommentEntity GetItemCommentByItem(int itemId, IConnection conn)
        {
            List<ItemCommentEntity> itemCommentList = new List<ItemCommentEntity>();

            string sql = "SELECT itemCommentId, itemFK, commentorFK, commentText, isHiddenFromOwner, updateTimestamp, updatePersonFK FROM dbo.itemComment WHERE itemId = @itemId;";
            List<SqlParameter> prms = new List<SqlParameter>();

            var paramQuery = new SqlParameter
            {
                ParameterName = "@itemId",
                Value = itemId
            };
            prms.Add(paramQuery);

            var rdr = conn.ExecuteReader(sql,prms);
            while (rdr.Read())
            {
                var itemComment = new ItemCommentEntity()
                {
                    itemCommentId = rdr.IsDBNull(rdr.GetOrdinal("itemCommentId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemCommentId")),
                    itemFK = rdr.IsDBNull(rdr.GetOrdinal("itemFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("itemFK")),
                    commentorFK = rdr.IsDBNull(rdr.GetOrdinal("commentorFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("commentorFK")),
                    commentText = rdr.IsDBNull(rdr.GetOrdinal("commentText")) ? null : rdr.GetString(rdr.GetOrdinal("commentText")),
                    isHiddenFromOwner = rdr.IsDBNull(rdr.GetOrdinal("isHiddenFromOwner")) ? true : (rdr.GetString(rdr.GetOrdinal("isHiddenFromOwner")) == "Y"),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                itemCommentList.Add(itemComment);
            }
            return itemCommentList.FirstOrDefault();
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:31,代码来源:ItemCommentRepository.cs

示例15: GetListById

        public GiftListEntity GetListById(int id, IConnection conn)
        {
            List<GiftListEntity> giftListlist = new List<GiftListEntity>();

            string sql = "SELECT giftListId, personFK, listName, isPrivate, updateTimestamp, updatePersonFK FROM DBO.GIFTLIST WHERE giftListId = @id;";
            List<SqlParameter> prms = new List<SqlParameter>();

            var paramId = new SqlParameter
            {
                ParameterName = "@id",
                Value = id
            };
            prms.Add(paramId);

            var rdr = conn.ExecuteReader(sql,prms);
            while (rdr.Read())
            {
                var giftList = new GiftListEntity()
                {
                    giftListId = rdr.IsDBNull(rdr.GetOrdinal("giftListId")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("giftListId")),
                    personFK = rdr.IsDBNull(rdr.GetOrdinal("personFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("personFK")),
                    listName = rdr.IsDBNull(rdr.GetOrdinal("listName")) ? null : rdr.GetString(rdr.GetOrdinal("listName")),
                    isPrivate = rdr.IsDBNull(rdr.GetOrdinal("isPrivate")) ? false : (rdr.GetString(rdr.GetOrdinal("isPrivate")) == "Y"),
                    updateTimestamp = rdr.IsDBNull(rdr.GetOrdinal("updateTimestamp")) ? new DateTime() : rdr.GetDateTime(rdr.GetOrdinal("updateTimestamp")),
                    updatePersonFK = rdr.IsDBNull(rdr.GetOrdinal("updatePersonFK")) ? -1 : rdr.GetInt32(rdr.GetOrdinal("updatePersonFK"))
                };
                giftListlist.Add(giftList);
            }
            return giftListlist.FirstOrDefault();
        }
开发者ID:greinedt,项目名称:GiftList,代码行数:30,代码来源:GiftListRepository.cs


注:本文中的IConnection.ExecuteReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。