MyDbEntities context = new MyDbEntities();var result = context.StoredProcedureName(userId);In the situation above, is it considered best practice to use var or ObjectResult<ComplexType>?
Is it considered best practice to dynamically bind return types from the Entity context?
c#;.net;entity framework
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.var should be used only when the implicit type is discoverable in the same line of code or very nearby.In your example, you should really use ObjectResult<ComplexType>:ObjectResult<ComplexType> result = context.StoredProcedureName(userId);These cases are ok for var, because the types are easily discernible:var user = context.Users.First(x => x.Id == userId);orvar users = context.Users.Where(x => x.LastName == lastName);foreach(var user in users){  //do stuff}