The specification must have Selector defined - how is it mapped to a dto? #599
ThomasVague
started this conversation in
General
Replies: 1 comment 1 reply
-
How are you using the specification exactly? You shouldn't have to do a "select"... that happens behind the scenes by using a specification that has 2 type parameters. (In our implementation it actually uses mapster's projectToType method, so the mapping is actually done when querying the database. ==> see ApplicationDbRepository.ApplySpecification) But when using the GetBySpecAsync method, you have to cast the spec so the right overload is used: await _repository.GetBySpecAsync(
(ISpecification<Brand, BrandDto>)new BrandByIdSpec(request.Id), cancellationToken) Maybe that is the culprit? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, quick question.
I'm trying to implement some of the pagination features into my own project, and I get this error when I try to use a specification with the <T, TResult> implementation. When I add a Select statement to the specification, and map the properties, it works fine.
But in the FSH repo there is no Select, it just does the mapping without any error. I only have two properties in my entity and dto; Id and Description, and they are of the same types, so I just find it puzzing that it's not working for me. I've copied over the "base" specifcations and extensions used, so everything is the same.
Beta Was this translation helpful? Give feedback.
All reactions