Reputation: 788
I am new with the entity framework. I have a dashboard with widgets and this is my table in Microsoft SQL server.
The reason I have widgets as a blob and not as a seperated entity is because I am not gonna query on the widgets table. Only data like SELECT * FROM Dashboard WHERE dashboardid =x
This is my DashboardDAL class:
public class DashboardDAL
{
public Dashboard GetDashboardPerUser()
{
throw new NotImplementedException();
}
public string AddWidget()
{
throw new NotImplementedException();
}
}
I want to add a widget with the entity framework. A Json object of a widget looks like this:
{name:"Weather", dashboardid:"2", userID:"4", "x":1,"y":0,"width":3,"height":1}
How can I add a widget object and save it as a BLOB in the database?
Kind regards
Upvotes: 0
Views: 1379
Reputation: 89071
JSON is a string. Use a string property on an entity to store it with EF. This will map to a NVARCHAR(MAX) column in SQL Server, which is the correct type for storing JSON in SQL Server.
Upvotes: 3