示例#1
0
 protected GenericObjectFactoryBase(IUnitOfWork unitOfWork, IUniqueKeyRepository <TE, TK> repository,
                                    TB businessObject)
     : base(unitOfWork)
 {
     Repository     = repository;
     BusinessObject = businessObject;
 }
示例#2
0
 public static bool ValidateUniqueKey <TEntity, TKey, TUserKey>(this ValidationResult result, TEntity entity, IUniqueKeyRepository <TEntity, TKey, TUserKey> repository)
     where TEntity : class, IKey, IEntity <TKey, TUserKey>
     where TKey : struct, IEquatable <TKey>
     where TUserKey : struct, IEquatable <TUserKey>
 {
     if (result.ValidateKey(entity))
     {
         TKey id = repository.GetID(entity.Key);
         if (!default(TKey).Equals(id) && !entity.ID.Equals(id))
         {
             result.AddError(nameof(entity.Key), $"Key {entity.Key} is duplicated");
         }
         else
         {
             return(true);
         }
     }
     return(false);
 }