-
-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Discussed in #251
Originally posted by Brandejs February 17, 2025
Hello,
First thanks for this project, it is really useful.
I am curious if it is possible to use an existing GridifyMapper and apply it to a "complex object". For example, I have an object Address. And I want to allow filtering only over some properties. The object is used in multiple entities, so I would like to restrict the given property on all entities. Similar to AutoMapper, where a DTO can be embedded and the correct map is used for it.
public class Address
{
public string City { get; set; }
public string Country { get; set; }
public string Secret { get; set; }
}
public class User
{
public string Email { get; set; }
public Address Address { get; set; }
// ....
}
public class Company
{
public string Name { get; set; }
public Address Address { get; set; }
// ....
}
public class AddressGridifyMapper : GridifyMapper<Address>
{
public AddressGridifyMapper()
{
AddMap("City", q => q.City);
AddMap("Country", q => q.Country);
// This field should not be allowed to filter
// RemoveMap(nameof(Address.Secret))
}
}
public class UserGridifyMapper : GridifyMapper<User>
{
public UserGridifyMapper()
{
AddMap("Email", q => q.Email);
// Reuse Mapper from AddressGridifyMapper
AddMap("Address", q => q.Address);
}
}
public class CompanyGridifyMapper : GridifyMapper<Company>
{
public CompanyGridifyMapper()
{
AddMap("CompanyName", q => q.Name);
// Reuse Mapper from AddressGridifyMapper
AddMap("Address", q => q.Address);
}
}
```</div>Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers