Hi
Sorry for re-opening this subject but i have issue when trying to save entity :
` public virtual async Task CreateOrEdit(CreateOrEditTacheDto input) { if (input.Id == null) { await Create(input); } else { var taskForperson1 = new PersonTacheDto(); var taskForperson2 = new PersonTacheDto();
taskForperson1.Id = 16;
taskForperson2.Id = 17;
taskForperson1.TacheId = 4;
taskForperson2.TacheId = 4;
input.Persons.Add(taskForperson1);
input.Persons.Add(taskForperson2);
await Update(input);
}
}`
Automapper issue
AutoMapper.AutoMapperMappingException: Error mapping types.
Mapping types: CreateOrEditTacheDto -> Tache ERUDY.Commercial.Dtos.CreateOrEditTacheDto -> ERUDY.Commercial.Tache
Type Map configuration: CreateOrEditTacheDto -> Tache ERUDY.Commercial.Dtos.CreateOrEditTacheDto -> ERUDY.Commercial.Tache
Destination Member: Persons
---> AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.
Mapping types: PersonTacheDto -> Person ERUDY.Commercial.Dtos.PersonTacheDto -> ERUDY.Commercial.Person at lambda_method4386(Closure, PersonTacheDto, Person, ResolutionContext) at lambda_method4385(Closure, CreateOrEditTacheDto, Tache, ResolutionContext) --- End of inner exception stack trace --- at lambda_method4385(Closure, CreateOrEditTacheDto, Tache, ResolutionContext) at Abp.AutoMapper.AutoMapperObjectMapper.Map[TSource,TDestination](TSource source, TDestination destination) at ERUDY.Commercial.TachesAppService.Update(CreateOrEditTacheDto input) in C:\Users\Bernard\source\repos\Erudy\src\ERUDY.Application\Commercial\TachesAppService.cs:line 185 at Abp.Authorization.AuthorizationInterceptor.InternalInterceptAsynchronous(IInvocation invocation) at ERUDY.Commercial.TachesAppService.CreateOrEdit(CreateOrEditTacheDto input) in C:\Users\Bernard\source\repos\Erudy\src\ERUDY.Application\Commercial\TachesAppService.cs:line 163 at Abp.Authorization.AuthorizationInterceptor.InternalInterceptAsynchronous(IInvocation invocation) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker....
Thks a lot for this reply
Hi,
I add following implementation : https://docs.aspnetzero.com/en/aspnet-core-mvc/latest/Feature-Dynamic-Entity-Parameters-Custom-Input-Types-Mvc
But how does this field work is asp Core project any example ?
Thks
Thks for explanation
So, I have a stupid question how to add a task to the person entity without having a PersonTache entity in the dbcontext. The table was created by itself in the database
This way (mapping from multiselect field and) ?
public class CreateOrEditTacheDto : EntityDto<int?> {
[Required]
[StringLength(TacheConsts.MaxIntituleLength, MinimumLength = TacheConsts.MinIntituleLength)]
public string Intitule { get; set; }
public DateTime Echeance { get; set; }
public Priorite Priorite { get; set; }
public TypeTache TypeTache { get; set; }
public long UserId { get; set; }
public List<PersonDto> Persons { get; set; }
}
Hi @m.aliozkaya,
For the 2 cases the results are 0
And same result for searching Tasks (tache in french) in personappservice :
var dbListPerson = _personRepository.GetAllIncluding(x => x.Taches).Where(x => x.Id == input.Id).ToList(); var dbListPerson2 = _personRepository.GetAllIncluding(x => x.Taches).FirstOrDefault(x => x.Id == input.Id);
Hi
Thks for quick answer
If you look above it is the same code as you
var dbList = _tacheRepository.GetAllIncluding(x => x.Persons).Where(x => x.Id == tache.Id);
But no data is returned for person entity
Hi,
I have a many to many relation entity for Person and Tache (task in English) but the Persons data in not displayed when calling the task entity ?
Person Entity : ...... public List<Tache> Taches { get; set; }
Tache Entity
public List<Person> Persons { get; set; }
Request :
var dbList = _tacheRepository.GetAllIncluding(x => x.Persons).Where(x => x.Id == tache.Id); var dbList2 = _tacheRepository.GetAll().Include(x => x.Persons).Where(x => x.Id == tache.Id);
the model creating
` modelBuilder.Entity
modelBuilder.Entity<Tache>()
.HasMany(e => e.Persons)
.WithMany(e => e.Taches)
.UsingEntity("PersonTache");
`
database
Any idea ?
Thks
Hi It’s not a modal view
Hi Yes from server From App.Services CreateOrEdit method do you mean ?
I would like returned entity Id without closing view to be able to add related other entities
For example Person Id for passing id to quote entity foreign Key person.id in same view without closing it
This for help and example