コード例 #1
0
        public TestEmployee Add(TestEmployee item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            // TO DO : Code to save record into database
            item.Id = _nextId++;
            this._data.Add(item);
            return item;
        }
コード例 #2
0
        public bool Update(TestEmployee item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            // TO DO : Code to update record into database
            int index = this._data.FindIndex(p => p.Id == item.Id);
            if (index == -1)
            {
                return false;
            }
            this._data.RemoveAt(index);
            this._data.Add(item);
            return true;
        }
コード例 #3
0
        public static List<TestEmployee> GetEmployees(List<int> ids)
        {
            List<TestEmployee> list = null;

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

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

                   paramCollection.Add(p);

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

                   p.Id = reader.GetSafeInt32(startingIndex++);
                   p.LastName = reader.GetSafeString(startingIndex++);

                   p.FirstName = reader.GetSafeString(startingIndex++);
                   p.Title = reader.GetSafeString(startingIndex++);
                   p.Dob = reader.GetSafeDateTime(startingIndex++);
                   p.Status = reader.GetSafeInt32(startingIndex++);

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

                   list.Add(p);
               }
               );

            return list;
        }
コード例 #4
0
        internal static List<Domain.Tests.TestEmployee> GetEmployees()
        {
            List<TestEmployee> list = null;

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

                   p.Id = reader.GetSafeInt32(startingIndex++);
                   p.LastName = reader.GetSafeString(startingIndex++);

                   p.FirstName = reader.GetSafeString(startingIndex++);
                   p.Title = reader.GetSafeString(startingIndex++);
                   p.Dob = reader.GetSafeDateTime(startingIndex++);
                   p.Status = reader.GetSafeInt32(startingIndex++);

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

                   list.Add(p);
               }
               );

            return list;
        }
コード例 #5
0
 public bool Update(TestEmployee item)
 {
     throw new NotImplementedException();
 }