I'm on the way to implement some authorization into my application. I want to achieve that a user with some role and permission can only see some o the attributes. Take a look:
// User Model
string lastname;
string firstname;
string birthdate;
Let's say the user is administrator so he can see all users but he is not allowed to see the users birthdate.
I've created a class that returns a List of all allowed attributes (as you an see only first- and lastname):
public class AllowedAttributes
{
private List<string> AllowedAttributes = new List<string>();
public AllowedAttributes()
{
this.AllowedAttributes.Add("lastname");
this.AllowedAttributes.Add("firstname");
}
public List<string> GetAllowedAttributes()
{
return this.AllowedAttributes;
}
}
My NHibernate query looks as follows:
AllowedAttributes attributes = new AllowedAttributes();
var user = sessionService.GetDefaultSession()
.Query<User>()
// something like...
// .Select(attributes.GetAllowedAttributes())
.ToList();
Can somebody help me out with a correct NHibernate query? I only want to get the attributes specified in the list.
P.S. In my application the list is way longer, so just typing the Attributes is not working.
Thanks in advance :)