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

Activities of "aaron"

Put that in appsettings.json:

"App": {
  "AllowSwaggerToRunAPIs": "true"
}

And get it in Startup.cs:

if (bool.Parse(_appConfiguration["App:AllowSwaggerToRunAPIs"])) {
    // ...
}

You definitely need to update VS and NuGet.

.NET Core is not a dependency, but the SDK is for .NET Standard 2.0.

When I try your code with an empty entity2, it results an empty EntityDto. It should be an EntityDto with values of all PropertyFromEntity1 but null for all PropertyFromEntity2. I reversed the order of mapping and solved it. Is it the correct way?

Yes, that's AutoMapper behavior for null source. Alternatively, you can add a null-check.

I want to keep entity1.Id as EntityDto.Id and ignore entity2.Id. When I try your code, it returns the EntityDto.Id = entity2.Id, because the last mapping is on the entity2, I think. I surely can reverse the order of mapping in this particular example to solve this issue...

Yes, map the overriding one last.

...but generally, how do I handle if entity1 and entity2 have same name properties?

Create a Profile:

public class EntityListDtoProfile : Profile
{
    public EntityListDtoProfile()
    {
        CreateMap<Entity1, EntityListDto>()
            .ForMember(dest => dest.ABC, opt => opt.Ignore()); // ignore Entity1.ABC

        CreateMap<Entity2, EntityListDto>()
            .ForMember(dest => dest.XYZ, opt => opt.Ignore()); // ignore Entity2.XYZ
    }
}

Add profiles by assembly scanning in the PreInitialize method of YourApplicationModule:

Configuration.Modules.AbpAutoMapper().Configurators.Add(cfg =>
{
    cfg.AddProfiles(typeof(YourApplicationModule).GetAssembly());
});;

Your entity is anonymous type since you GroupJoin with new, so the mapping is unsupported.

Do this:

public EntityListDto GetEntity(int Id)
{
    var entity1 = _entity1Repository.Get(Id);

    var entity2 = _entity2Repository.FirstOrDefault(w => w.FKId == Id);

    var dto = ObjectMapper.Map<EntityListDto>(entity1);

    return ObjectMapper.Map(entity2, dto);
}

Generic types are not registered by convention.

You need to register it manually:

IocManager.Register(typeof(IImportDataManager<,,>), typeof(ImportDataManager<,,>), DependencyLifeStyle.Transient);

Did you install .NET Core 2.0 SDK?

Answer

Are you using NuGet 4.3+?

Answer

Did you supply the initial row version? What's not working?

You should not need to implement a custom repository for this.

Are you using VS 2017 15.3.3+ and NuGet 4.3+?

Showing 1341 to 1350 of 1543 entries