Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "agmachado"

Hi robmarsh00 Did you find any solution? can you share it? Thank you

your indications worked Thank you

Yes

[AutoMapFrom(typeof(CampoModulo))] [AutoMapTo(typeof(CampoModulo))] public class CamposEnModuloEditDto ....

[AutoMapFrom(typeof(CampoModulo))] [AutoMapTo(typeof(CampoModulo))] public class CamposEnModuloEditDto ......

Thank for your reply ismcagdas

My reduced sample code:

public class ModuloPl : Entity { public virtual string Nombre { get; protected set; } public virtual string Html { get; set; } public ICollection<CampoModulo> Campos { get; set; } .... }

public class CampoModulo : Entity { public virtual string Nombre { get; set; } public virtual string Marca { get; set; } public virtual bool Requerido { get; set; } .... }

public class ModuloPlEditDto { public virtual int? Id { get; set; } public virtual string Nombre { get; set; } public virtual string Html { get; set; } public Collection<CamposEnModuloEditDto> Campos { get; set; } }

public class CamposEnModuloEditDto { public virtual int? Id { get; set; } public string Nombre { get; set; } public string Marca { get; set; } public bool Requerido { get; set; } }

private async Task<ModuloPl> GetModuloByIdAsync(int moduloId) { var modulopl = await _moduloRepository.GetAll() .Include(p => p.Campos) .Include(p => p.imagen) .Include(p => p.imagen.Ubicacion) .Where(p => p.Id == moduloId).SingleAsync();

if (modulopl == null)
{
    throw new Abp.UI.UserFriendlyException("No existe ningún módulo con id: " + moduloId);
}

return modulopl;

}

Now, in runtime, the user add a new CamposEnModuloEditDto in a existing ModuloPlEditDto

ModuloPlEditDto input; // this DTO is mapped from a existting entity CamposEnModuloEditDto newCampo = new CamposEnModuloEditDto(); newCampo.Nombre = "name"; newCampo.Marca = "Html"; newCampo.Requerido = True; input.Campos.Add(newCampo);

and calll to UpdateModuloPl(ModuloPlEditDto input)

[AbpAuthorize(AppPermissions.Pages_Administration_TAuxiliares)] public async Task UpdateModuloPl(ModuloPlEditDto input) {

 var oldmodulopl = await GetModuloByIdAsync(input.Id.Value);

ObjectMapper.Map(input, oldmodulopl);

await _moduloRepository.UpdateAsync(oldmodulopl);

}

Mvc.ExceptionHandling.AbpExceptionFilter - The instance of entity type 'CampoModulo' cannot be tracked because another instance of this type with the same key is already being tracked. When adding new entities, for most key types a unique temporary key value will be created if no key is set (i.e. if the key property is assigned the default value for its type). If you are explicitly setting key values for new entities, ensure they do not collide with existing entities or temporary values generated for other new entities. When attaching existing entities, ensure that only one entity instance with a given key value is attached to the context. System.InvalidOperationException: The instance of entity type 'CampoModulo' cannot be tracked because another instance of this type with the same key is already being tracked. When adding new entities, for most key types a unique temporary key value will be created if no key is set (i.e. if the key property is assigned the default value for its type). If you are explicitly setting key values for new entities, ensure they do not collide with existing entities or temporary values generated for other new entities. When attaching existing entities, ensure that only one entity instance with a given key value is attached to the context. en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap1.Add(TKey key, InternalEntityEntry entry) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap1.Add(InternalEntityEntry entry) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking(InternalEntityEntry entry) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState oldState, EntityState newState, Boolean acceptChanges) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState entityState, Boolean acceptChanges) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction(EntityEntryGraphNode node) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph(EntityEntryGraphNode node, Func2 handleNode) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph(InternalEntityEntry rootEntry, EntityState entityState) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.NavigationFixer.NavigationCollectionChanged(InternalEntityEntry entry, INavigation navigation, IEnumerable1 added, IEnumerable1 removed) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntryNotifier.NavigationCollectionChanged(InternalEntityEntry entry, INavigation navigation, IEnumerable1 added, IEnumerable1 removed) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.ChangeDetector.DetectNavigationChange(InternalEntityEntry entry, INavigation navigation) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.ChangeDetector.DetectChanges(InternalEntityEntry entry) en Microsoft.EntityFrameworkCore.ChangeTracking.Internal.ChangeDetector.DetectChanges(IStateManager stateManager) en Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker.DetectChanges() en Microsoft.EntityFrameworkCore.ChangeTracking.ChangeTracker.Entries() en Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.AttachIfNot(TEntity entity) en Castle.Proxies.EfCoreRepositoryBase2Proxy_4.AttachIfNot_callback(ModuloPl entity) en Castle.Proxies.Invocations.EfCoreRepositoryBase3_AttachIfNot_27.InvokeMethodOnTarget() en Castle.DynamicProxy.AbstractInvocation.Proceed() en Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options) en Abp.Domain.Uow.UnitOfWorkInterceptor.PerformUow(IInvocation invocation, UnitOfWorkOptions options) en Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) en Castle.DynamicProxy.AbstractInvocation.Proceed() en Castle.Proxies.EfCoreRepositoryBase2Proxy_4.AttachIfNot(ModuloPl entity) en Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.UpdateAsync(TEntity entity) en Castle.Proxies.EfCoreRepositoryBase2Proxy_4.UpdateAsync_callback(ModuloPl entity) en Castle.Proxies.Invocations.EfCoreRepositoryBase3_UpdateAsync_27.InvokeMethodOnTarget() en Castle.DynamicProxy.AbstractInvocation.Proceed() en Abp.Domain.Uow.UnitOfWorkInterceptor.PerformAsyncUow(IInvocation invocation, UnitOfWorkOptions options) en Abp.Domain.Uow.UnitOfWorkInterceptor.PerformUow(IInvocation invocation, UnitOfWorkOptions options) en Abp.Domain.Uow.UnitOfWorkInterceptor.Intercept(IInvocation invocation) en Castle.DynamicProxy.AbstractInvocation.Proceed() en Castle.Proxies.EfCoreRepositoryBase`2Proxy_4.UpdateAsync(ModuloPl entity) en icaCronos.Plantilla.ModuloPlAppService.

Hi ismcagdas

Thanks for your reply

Authentication / permission check is not required because is a local service but i would like use the same database that i defined in myproject.EntityFrameworkCore and the same librarys classes and methods defined in myproject.Application and myproject.Core

I would like use localization and time zone settings too

Thanks

Hi. Is it possible to get an updated version of the example that you are referring in this post?

I am trying to create a standalone windows service that uses abp to get list of Entity's and send email Thanks

Showing 1 to 6 of 6 entries