-
Notifications
You must be signed in to change notification settings - Fork 1
Parameterized Mapping
Dima Bezzubenkov edited this page Sep 4, 2021
·
4 revisions
Parameterized Mapping is a mapping type that can take input arguments and you can use them in expression.
Parameterized mapping is a function that takes input arguments as a model and returns expression. Returned expression describes how one model can be mapped to another model:
mapping.Add<Appartment, AppartmentModel, AppartmentsArguments>(args =>
{
return x => new AppartmentModel
{
Id = x.Id,
Badrooms = x.Badrooms,
Bathrooms = x.Bathrooms,
Floor = x.Floor,
IsLodge = x.IsLodge,
Number = x.Number,
Size = x.Size.ToString() + args.UnitOfMeasure
};
});You can apply Parameterized Mapping to a query by using one of AsQuery overloads:
IQueryable<Appartments> query = ...;
var arguments = new AppartmentsArguments { UnitOfMeasure = "sq ft" };
var list = _qmService.AsQuery<Appartment, AppartmentShortModel, AppartmentsArguments>(query, arguments).ToList();To see more advanced examples please check Advanced Mappings