MyDbEntities context = new MyDbEntities();
var result = context.StoredProcedureName(userId);
In the situation above, is it considered best practice to use var or ObjectResult<ComplexType>?
In the situation above, is it considered best practice to use |
|||
|
|
Generally, if you can't tell the return type by reading the line in question (or another, very nearby line), you should use the explicit type. This will make the readability of your code much better.
In your example, you should really use
These cases are ok for
or
|
|||
|
|
|
I would have no problem using
For what it's worth, when you use var, you're not dynamically binding anything. The compiler AND the IDE know what type (even if it's just It would be different if you used |
|||
|
|