1. 程式人生 > >應用程式框架實戰二十:對映層超型別

應用程式框架實戰二十:對映層超型別

using System; using System.ComponentModel.DataAnnotations.Schema; using Util.Domains; namespace Util.Datas.Ef { /// <summary> /// 聚合根對映 /// </summary> /// <typeparam name="TEntity">聚合根型別</typeparam> /// <typeparam name="TKey">實體標識型別</typeparam> public
abstract class AggregateMapBase<TEntity, TKey> : EntityMapBase<TEntity> where TEntity : AggregateRoot<TKey> { /// <summary> /// 對映標識 /// </summary> protected override void MapId() { HasKey( t => t.Id ); } /// <summary>
/// 對映屬性 /// </summary> protected override void MapProperties() { Property( t => t.Version ).HasColumnName( "Version" ).IsRowVersion().HasDatabaseGeneratedOption( DatabaseGeneratedOption.Computed ).IsOptional(); } } /// <summary> ///
聚合根對映 /// </summary> /// <typeparam name="TEntity">聚合根型別</typeparam> public abstract class AggregateMapBase<TEntity> : AggregateMapBase<TEntity, Guid> where TEntity : AggregateRoot<Guid> { } }