Skip to content

Contains in Linq #35

@adria-arquimbau

Description

@adria-arquimbau

I have an issue and don't know how to solve it. Having 4 string fields from one entity I decided to change one of them "SerialNumber" to a value object.

At some point having an IQueryable I need to filter for the items that contain a similar search term, in this example details. There is no problem with using .Contains for any string fields but when I change SerialNumber to ValueObject and I don't have the Contain method anymore.

return query.Where(x =>
                x.Number.Contains(details) ||
                x.SerialNumber.Value.Contains(details) || //New field as string ValueObject
                x.Name.Contains(details) ||
                x.CarrierName.Contains(details));

I tried to use x.SerialNumber.Value.Contains(details), details.Contains(x.SerialNumber.Value) and some other approaches. And responding with the following error: Could not be translated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions