Does anyone know how I can select a row and column dynamically in EF4? (VB)
A bit like a map, I want to navigate through the data using x and y axis to pull out one fields value,
SQL would look like this
SELECT ” & MyColumbVariable & ” FROM MyTable WHERE MyRow = ” & MyVariable & “
Bit of a hack I know its not great. Perhaps there is a cleaner way to do this?
Thanks
You can use
CreateQuerymethod of object context. Assuming you are using 4.1+:If you’re using 4.0 there’s no need to cast to
IObjectContextAdaptersince your context is alreay of typeObjectContext.Update:
You can also build expression trees yourself to build dynamic queries. It’s a bit of work but you can use it everywhere by writing it in a generic way. A good sample has been explained here. Also search for Dynamic Queries/Building expression trees in Entity Framework and you’ll find some good tutorials.