Ejemplo n.º 1
0
        /// <summary>
        /// Uses reflection to set the Id of a <see cref="EntityWithTypedId{IdT}" />.
        /// </summary>
        public static void SetIdOf <IdT>(IDomainObjectWithTypedId <IdT> entity, IdT id)
        {
            // Set the data property reflectively
            PropertyInfo idProperty = entity.GetType().GetProperty("Id",
                                                                   BindingFlags.Public | BindingFlags.Instance);

            Check.Ensure(idProperty != null, "idProperty could not be found");

            idProperty.SetValue(entity, id, null);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Uses reflection to set the Id of a <see cref="EntityWithTypedId{IdT}" />.
 /// </summary>
 public static IDomainObjectWithTypedId <TId> SetIdTo <TId>(this IDomainObjectWithTypedId <TId> entity, TId id)
 {
     SetIdOf(entity, id);
     return(entity);
 }