コード例 #1
0
        public static List<Communication> GetAll()
        {
            List<Communication> list = new List<Communication>();

            DataProvider.ExecuteCmd(GetConnection, "dbo.Communications_Select"
               , inputParamMapper: delegate(SqlParameterCollection paramCollection) { }

               , map: delegate(IDataReader reader, short set)
               {
                   Communication p = new Communication();
                   int startingIndex = 0;

                   p.Id = reader.GetSafeInt32(startingIndex++);
                   p.Name = reader.GetSafeString(startingIndex++);
                   p.Email = reader.GetSafeString(startingIndex++);
                   p.Subject = reader.GetSafeString(startingIndex++);
                   p.Message = reader.GetSafeString(startingIndex++);
                   p.Date = reader.GetSafeDateTime(startingIndex++);
                   p.UserId = reader.GetSafeString(startingIndex++);

                   if (list == null)
                   {
                       list = new List<Communication>();
                   }
                   list.Add(p);

               }
               );

            return list;
        }
コード例 #2
0
        public static Communication GetById(int Id)
        {
            Communication p = new Communication();

            DataProvider.ExecuteCmd(GetConnection, "dbo.Communications_SelectById"
               , inputParamMapper: delegate(SqlParameterCollection paramCollection)

               { paramCollection.AddWithValue("@Id", Id); }

               , map: delegate(IDataReader reader, short set)
               {

                   int startingIndex = 0; //startingOrdinal

                   p.Id = reader.GetSafeInt32(startingIndex++);
                   p.Name = reader.GetSafeString(startingIndex++);
                   p.Email = reader.GetSafeString(startingIndex++);
                   p.Subject = reader.GetSafeString(startingIndex++);
                   p.Message = reader.GetSafeString(startingIndex++);
                   p.Date = reader.GetSafeDateTime(startingIndex++);
                   p.UserId = reader.GetSafeString(startingIndex++);

               }
               );

            return p;
        }