I have a simple data layer routine that performs a password update, the user passes in the following:
- Current Password, New Password, Confirm New Password.
In my data layer (proc) checks a couple things such as:
- Is the current password correct?
- Is the new password and confirm password correct?
- Has the new password been assigned in the past?
And so on…
Now I know I can simply create a class and returned a couple booleans:
public class UpdatePasswordResponse{
public bool CurrentPasswordCorrect {get;set;}
....(and so on)
}
But is there a way I can dynamically return that information to the biz layer in properties instead of creating a new class everytime (for every data layer routine)? I seem to remember thinking this was possible. I am pretty sure I read it somewhere but don’t remember the syntax, can someone help me?
You can do this in .NET 4 with the use of the
dynamickeyword.The class you will want to return would be an ExpandoObject.
Basically, follow this pattern: