protected override object ReadRow(IRowReader reader)
        {
            HomepageCategory homepageCategory = HomepageCategory.New();

            // Table Fields
            homepageCategory.HomepageCategoryId = reader.GetInt32("HomepageCategoryId");
            homepageCategory.HomepageId         = reader.GetInt32("HomepageId");
            homepageCategory.CategoryId         = reader.GetInt32("CategoryId");
            homepageCategory.OrderBy            = reader.GetInt32("OrderBy");


            homepageCategory.IsDirty = false;
            homepageCategory.ChangedProperties.Clear();

            return(homepageCategory);
        }
        public virtual HomepageCategory Update(HomepageCategory homepageCategory)
        {
            if (!homepageCategory.IsDirty || homepageCategory.IsNull)
            {
                // Nothing to do - no point hammering the database unnecessarily
                return(homepageCategory);
            }

            IDbCommand command = CreateCommand();

            if (homepageCategory.IsNew)
            {
                // Adding
                command.CommandText = "INSERT INTO [HomepageCategory] ([HomepageId], [CategoryId], [OrderBy]) VALUES (@homepageId, @categoryId, @orderBy) ; SELECT @@identity AS NewId;";
            }
            else
            {
                // Updating
                command.CommandText = "UPDATE [HomepageCategory] SET [HomepageId] = @homepageId, [CategoryId] = @categoryId, [OrderBy] = @orderBy WHERE HomepageCategoryId = @homepageCategoryId";
            }

            command.Parameters.Add(CreateParameter("@homepageId", homepageCategory.HomepageId));
            command.Parameters.Add(CreateParameter("@categoryId", homepageCategory.CategoryId));
            command.Parameters.Add(CreateParameter("@orderBy", homepageCategory.OrderBy));

            if (homepageCategory.IsNew)
            {
                homepageCategory.HomepageCategoryId = Convert.ToInt32(ExecScalar(command));
            }
            else
            {
                command.Parameters.Add(CreateParameter("@homepageCategoryId", homepageCategory.HomepageCategoryId));
                ExecuteCommand(command);
            }

            homepageCategory.IsDirty = false;
            homepageCategory.ChangedProperties.Clear();

            return(homepageCategory);
        }
Ejemplo n.º 3
0
        public static HomepageCategory FindOne(HomepageCategoryFinder finder)
        {
            HomepageCategory HomepageCategory = HomepageCategoryMapper.Instance.FindOne(finder);

            return(HomepageCategory ?? Empty);
        }
Ejemplo n.º 4
0
 public static HomepageCategory Update(HomepageCategory homepageCategory)
 {
     return(HomepageCategoryMapper.Instance.Update(homepageCategory));
 }
Ejemplo n.º 5
0
        public static HomepageCategory Get(Nullable <Int32> HomepageCategoryId)
        {
            HomepageCategory HomepageCategory = HomepageCategoryMapper.Instance.Get(HomepageCategoryId);

            return(HomepageCategory ?? Empty);
        }