How can I add an array to Entity Model in VS?
I want to store a histogram of an image in a database. In the program, the histogram is represented as an array of doublings (exactly 64)
What is the best way to add it to the entity model? (anything better than adding a complex type with multiple double values?)
PS If it matters - I am planning to generate my db from entity model.
+2
a source to share
1 answer
Create a separate Pattern instance with an Int index and a scalar Value property.
Add association from image to sample: 1 to many.
This will give you a navigation property in the image called "Samples" and you can do: -
image.Samples.OrderBy (s => s.Index). Select (s => s.Value) .ToArray () to restore the array.
This structure allows you to easily change the value 64.
Edit To create objects you can use Linq
var values = histogram.Select((d,i) => new Sample(){Index =i, Value = d});
var image = new Image(){ Samples = values };
0
a source to share