Entity Framework: EntityCommand automatically parsing and determine parameter types?
- by Torben Rahbek Koch
Hi everybody,
Pretty new to Entity Framework I must admit, but I simply cannot believe that there is no built-in solution for this problem.
Let's say I create an EntityCommand:
EntityCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = commandText;
And let's say the the commandText is something like this:
SELECT sp.UserName, sp.Rights FROM EntityContext.Users as sp
WHERE sp.UserName=@UserName
Now it would be really neat if the Parameters collection of cmd could be automatically filled. The framework should obviously know the types etc. but I guess that's simply not how it works beneath.
The problem is that the commandText is configurable on run-time, and I must show some GUI that asks for values of the parameters.
Any idea on how this could be accomplished?
Thanks for any ideas and for listening!