Entity Framework: EntityCommand automatically parsing and determine parameter types?

Posted by Torben Rahbek Koch on Stack Overflow See other posts from Stack Overflow or by Torben Rahbek Koch
Published on 2009-09-10T15:26:32Z Indexed on 2010/04/21 6:23 UTC
Read the original article Hit count: 625

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about c#