Add clone method to EntityExtensions

features/nuget_autobuild
Matija Koželj 2 years ago
parent 9209bada7a
commit 339dc635e5

@ -85,6 +85,14 @@ public static class EntitiesExtensions
return Serializer.Merge(newEntity, existing, modifier, new StateModifier { State = state }, sources);
}
public static TEntity Clone<TEntity>(this TEntity existing)
where TEntity : IEntity
{
var newEntity = Activator.CreateInstance<TEntity>();
return Serializer.Merge(newEntity, existing);
}
public static async Task<ImmutableList<TSource>> AsEntities<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default)
{
if (source is null)

Loading…
Cancel
Save