/// <summary>Create a new entity from DTO</summary> /// <typeparam name="T">Entity Type</typeparam> /// <typeparam name="T1">DTO Type</typeparam> /// <param name="objectWithChanges">DTO object</param> public virtual T InsertFromObject <T, T1>(T1 objectWithChanges) where T : class where T1 : class { T entity = CopyClass.CopyToNew <T, T1>(objectWithChanges); Insert(entity); return(entity); }
/// <summary>Update entity from another entity or DTO</summary> /// <typeparam name="T">entity type</typeparam> /// <typeparam name="T1">object with changes'type</typeparam> /// <param name="objectWithChanges">source entity or DTO with changed properties</param> /// <param name="key">Primary key of entity</param> public virtual void UpdateFromObject <T, T1>(T1 objectWithChanges, params object[] key) where T : class where T1 : class { var entity = GetByKey <T>(key); CopyClass.Copy(entity, objectWithChanges); Update(entity); }