Skip to content

Support for mapped JSON types in Postgres #99

@bhavishyachandra

Description

@bhavishyachandra

Looks like the json properties are mapped as navigation properties instead of scalar properties, despite being in the same table. Would be great if the GetColumnName() could also look at these navigation properties for determining the column name in such circurmstances.

My temporary solution for now was to make the column a string as I don't plan on querying it for now. I could see how this can get inconvenient as more people start using the native json column implementation in EF Core. I tried to implement a custom DbSchemaRetriever but was running into some strange errors during the design time. It'd also be great if we could add an inbuilt jsonb comparer for nested properties to check for equality on json objects in postgres. Thanks for creating this wonderful package, everything just works as expected.

`public class JsonbMethodCallConverter : IMethodCallVisitor
{
private readonly IExpressionVisitorFactory _visitorFactory;

public JsonbMethodCallConverter(IExpressionVisitorFactory visitorFactory)
{
    _visitorFactory = visitorFactory;
}


public bool IsApplicable(MethodCallExpression expression)
{
    return expression.Method.ReflectedType == typeof(JsonbEfCoreDesignTriggerExtensions) && expression.Method.Name == "ToJsonbNoOpEfComparer";
}


public SqlBuilder Visit(MethodCallExpression expression, VisitedMembers visitedMembers)
{
    var sqlBuilder = _visitorFactory.Visit(expression.Arguments.First(), visitedMembers);
    return sqlBuilder.Append("::jsonb");
}

}
`

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