Skip to content

Translate hstore access to SQL #212

Open
@davidkvc

Description

@davidkvc

Is there a way to query hstore columns using LINQ ?
I would expect something like this to work:

public class Product
{
   public int Id { get; set; }
   //This is correctly set as hstore in OnModelCreating
   public Dictionary<string, string> Tags { get; set; } 
}
ApplicationDbContext db = ...

var prods = db.Products.Where(p => p.Tags["Variant"].Equals("SD")).ToList();

However that WHERE statement is evaluated at client and I want it to be evaluated in db server.
I expect something like this to be generated
select * from "Products" where "Tags" -> 'Variant' = 'SD'

This works so everything is configured correctly.
var prods = db.Products.FromSql("select * from \"Products\" where \"Tags\" -> 'Variant' = 'SD'").ToList();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions