using EFModell;
using System;
using System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Reflection;

namespace de.WWWings.CodeOnly.Kontext
{


  /// <summary>
 /// Konvention 4:  Konvention, die DBDateAttribute anwendet
 /// </summary>
 public class DBDateAttributeConvention : Convention
 {
  public DBDateAttributeConvention()
  {
   Properties<DateTime>()
    .Where(x => x.GetCustomAttribute<DBDateAttribute>() != null)
              .Configure(c => c.HasColumnType("date"));
  }
 }

 ///// <summary>
 ///// Konvention, die DBDateAttribute anwendet
 ///// </summary>
 //internal class DBDateAttributeConvention :
 // AttributeConfigurationConvention<PropertyInfo, DateTimePropertyConfiguration, DBDateAttribute>
 //{
 // public override void Apply(
 //  PropertyInfo propertyInfo,
 //  DateTimePropertyConfiguration configuration,
 //  DBDateAttribute attribute)
 // {
 //   configuration.ColumnType = "date";
 // }
 //}
}
