Skip to content

LINQ expression value not set in Npgsql command #3985

@MeikelLP

Description

@MeikelLP

The following query

[StronglyTypedId(Template.Guid)]
public readonly partial struct ShopId;

var shopId = new ShopId(Guid.Parse("00000005-0000-0000-0000-000000000000"));

await _session.Query<Product>().Where(x => x.Shops.Any(s => s.ShopId== shopId)).ToPagedListAsync(pageNumber, pageSize, token);
// using strongly typed ID value
await _session.Query<Product>().Where(x => x.Shops.Any(s => s.ShopId.Value == shopId.Value)).ToPagedListAsync(pageNumber, pageSize, token);

will ignore the where condition or rather build wrong SQL:

-- $2 = 50
 select d.id, d.data, d.last_modified_by, d.mt_version, count(*) OVER() as total_rows from my_db.mt_doc_product as d where d.data -> 'Shops' @> $1 order by d.data ->> 'Name' LIMIT $2

Expected

$1 should be '[{"ShopId": "00000005-0000-0000-0000-000000000000"}]'

Actual

$1 = '[{}]'

From debugging I assume it's because _data is not set

Image

I think it's because the query can't handle strongly typed IDs?
I added my value types to marten via

options.RegisterValueType<ShopId>();

Workaround

Use raw SQL

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions