Reputation: 5581
I have a really poorly written legacy SQL Server Database that I need to code against. Unfortunately a lot of other legacy applications that haven't been updated are still running against this database. I figured I'd use the Entity Framework to cleanly code my C# application against it.
I have a table that looks like the following.
Vector
Unfortunately Vector.Info is a series of comma separated values that I need to be able to edit cleanly. Example an entry in Vector.Info could be: 150,-56,36,866 (they correspond to X,Y,Z,T in that particular order). I know this is a bad antipattern what's the best way to deal with this using the Entity Framework?
Upvotes: 1
Views: 360
Reputation: 15663
EF doesn't support table value functions, in the way they aren't composable so you can't use a query like
from c in Vectors
where fnInfo(c).Any(f=>f.X == 150)
select c
What you can do in this case is to create a view for VectorId, Name, Info, X, Y, Z, T
, because it seems the split is fixed, it always produces these coordinates.
In this way you can further use this view with other EF sets. You can create navigation properties as long as the view has PrimaryKey set in the model.
You have to deal with the updates. When one of coordinates is changed probably you'll have to split the string and recompose it with the new coordinates.
Upvotes: 1