This project is read-only.


Aggregate key keeping entity property name


I have an entity and viewmodel mapping differently named properties of $amounts. I configured the grid for ajax and client side Sum aggregation. The helper computes the aggregate ok, and puts the results into the GridModel object. The problem
is that the Aggregate result in the GridModel is keeping the key as the property name of the Entity, while it should be named after the property name of the ViewModel. I tried mapping the properties with GridModelMapper.CreateMap but
that didn't help.
Closed Jun 28, 2012 at 2:18 PM by Luis_Fernando


Luis_Fernando wrote May 2, 2012 at 1:40 PM

I have already identified the problem and I'm working on it.

Luis_Fernando wrote May 3, 2012 at 2:23 PM

I have already provided a solution to the problem, but Codeplex seems to be in some sort of maintenance and I can not send the release, you can download the latest version directly from the NuGet gallery.

As soon as I can I will send the release here as well.

Luis_Fernando wrote May 3, 2012 at 11:49 PM

Alex, can I consider this issue resolved?

Noyabronok wrote May 4, 2012 at 12:37 PM

negative. The issue persists. Got from official nuget. 15.123-beta

Luis_Fernando wrote May 4, 2012 at 1:47 PM

You kept mapping the properties with GridModelMapper.CreateMap or AutoMapper.Mapper.CreateMap?

Something like:

Mapper.CreateMap<Product, ProductModel>()
  .ForMember(trg => trg.ViewModelProp, opt => opt.MapFrom(src => "[Agreggates] " + src.ProductName));

GridModelMapper.CreateMap<Product, ProductModel>()
  .MapProperty(entity => entity.ProductName, viewmodel => viewmodel.ViewModelProp);

Noyabronok wrote May 4, 2012 at 2:36 PM

I mapped with both, but I didn't add the "[Aggregates]" in the mapping. I would think a regular automapper mapping is required for standar use scenarios. I even tried a reverse mapping with GridModelMapper

Luis_Fernando wrote Jun 8, 2012 at 6:00 PM

Hello Alex, sorry for the delay in responding. Please try again with the latest version, I've done several tests here and could not reproduce this problem. If the problem persists, please send me a test showing your results.

The "[Aggregates]" in the mappings was just to illustrate, of course you do not need it.

In the Sample project I'm mapping from "Product.ProductName" to "ProductModel.ViewModelProp" without any trouble.