I need assistance to query from a model that contains one table of a specific object (i.e. Products) and one table of its dynamic attributes.
Let's say that I can store a Chocolate
with attributes such as Price
, Color
, Weight
and also a Car
with attributes such as Engine
, Gears
, Color
.
In my example I have a table called Products with the following columns :
Id (Int),
Name (NVarchar)
I have another table called dynamicAttributes
with the following columns :
Id (int) -- of the attribute
ProductId (int) -- of the specific product
AttributeType (int) -- enum with the following values ("Color", "Price","Height", "Width".... )
StringValue -- of the product
IntValue -- of the product
DoubleValue -- of the product
BooleanValue -- of the product
I get from the client a list of attributes codes and a list of there values.
I can get value type (aka boolean, string, int) for each attribute.
What are my best options to query this model from my app ?
Dynamic sqls only ? Using Pivot keyword?