﻿using Microsoft.SqlServer.Management.Smo;
using System.Collections.Generic;
using System.Data.Entity.Core.Metadata.Edm;
using Vstack.Common.Extensions;
using Vstack.Services.Data.General;

namespace Vstack.Services.Data.Generator.TableTypes
{
    public class ModifyTableType : EntityTableType
    {
        private readonly EntityType entityType;

        public ModifyTableType(EntityType entityType, Database database)
            : base(database)
        {
            this.entityType = entityType;
        }

        protected override string Name
        {
            get
            {
                return Naming.GetModifyTableTypeName(this.entityType.Name);
            }
        }

        protected override IEnumerable<EdmProperty> GetProperties()
        {
            return this.entityType.Properties;
        }

        protected override bool IsPropertyNull(EdmProperty prop)
        {
            prop.ValidateNotNull();

            return prop.Nullable;
        }
    }
}