Пример #1
0
        //Wayne 8/7
        public static List<TestPerson> Get(bool demoError = true)
        {
            List<TestPerson> list = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.TestTable_Select"
               , inputParamMapper: null
               , map: delegate(IDataReader reader, short set)
               {
                   TestPerson p = new TestPerson();
                   int startingIndex = 0; //startingOrdinal

                   if (demoError)
                   {
                       p.Name = reader.GetString(startingIndex++);
                       p.Last = reader.GetString(startingIndex++);

                       p.Age = reader.GetInt32(startingIndex++);
                   }
                   else
                   {
                       p.Name = reader.GetSafeString(startingIndex++);
                       p.Last = reader.GetSafeString(startingIndex++);

                       p.Age = reader.GetSafeInt32(startingIndex++);
                   }

                   if (list == null)
                   {
                       list = new List<TestPerson>();
                   }

                   list.Add(p);
               }
               );

            return list;
        }
Пример #2
0
        public static List<TestPerson> StructuredDataTypes(Guid[] guids)
        {
            List<TestPerson> list = null;

            DataProvider.ExecuteCmd(GetConnection, "dbo.TestTable_Structured"
               , inputParamMapper: delegate(SqlParameterCollection paramCollection)
               {
                   SqlParameter p = new SqlParameter("@ParamName", System.Data.SqlDbType.Structured);

                   if (guids != null && guids.Any())
                   {
                       p.Value = new Sabio.Data.UniqueIdTable(guids);
                   }

                   paramCollection.Add(p);

               }, map: delegate(IDataReader reader, short set)
               {
                   TestPerson p = new TestPerson();
                   int startingIndex = 0; //startingOrdinal

                   p.Name = reader.GetSafeString(startingIndex++);
                   p.Last = reader.GetSafeString(startingIndex++);

                   p.Age = reader.GetSafeInt32(startingIndex++);

                   if (list == null)
                   {
                       list = new List<TestPerson>();
                   }

                   list.Add(p);
               }
               );

            return list;
        }