Cannot Translate Where Clause on Child Property #146
-
Hello, I am getting an Here is my setup: Models: public record CatalogLocation(Guid Id, string Name, CatalogAddress Address);
public record CatalogAddress(string Street1, string PostalCode, string City, string Region, string Country);
public class MerchantLocation {
public MerchantLocation(Guid id, string name, string street, string city, string region, string country, string postalCode);
} AutoMapper Config: cfg => {
cfg.AddExpressionMapping();
cfg.CreateProjection<MerchantLocation, CatalogAddress>()
.ForCtorParam(nameof(CatalogAddress.Street1), opt => opt.MapFrom(src => src.Street));
cfg.CreateProjection<MerchantLocation, CatalogLocation>()
.ForCtorParam(nameof(CatalogLocation.Address), opt => opt.MapFrom(src => src));
} The queries in question: // works
var query1 = _db.MerchantLocations
.UseAsDataSource(_config)
.For<CatalogLocation>()
.Where(cl => cl.Name == "Matthews Avos")
.ToList();
// cannot be translated
var query2 = _db.MerchantLocations
.UseAsDataSource(_config)
.For<CatalogLocation>()
.Where(cl => cl.Address.PostalCode == "28226")
.ToList(); When filtering on a top level item, such as I understand that I am filtering on Is this possible? Is there a mapping I can use to make this work? Any help on this would appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Not sure what's going on there - or the last time anyone maintained that part of the library. Have you considered using a helper like this one? |
Beta Was this translation helpful? Give feedback.
Not sure what's going on there - or the last time anyone maintained that part of the library.
Have you considered using a helper like this one?