Let me give you some direction
Do not use a propertie to get your data, use a method
like this:
//returns an enumeration of users filtered by the given expression
Public IEnumerable<User> GetUsers(Expression<Func<User, bool>> expression)
{
return db.Users.Where(expression);
}
// returns the first occurency of a user filtered by the given expression
Public User GetUser(Expression<Func<User, bool>> expression)
{
return db.Users.FirstOrDefault(expression);
}
usage:
var user = GetUser(u => u.Id == 1); // returns first occurency or null
var users = GetUsers(u => u.Id < 100);
and you have a label
, it is an object, with properties where you should set the information, so set your Name
to its Content
:
public WindowViewModel(Label userName)
{
var us = GetUser(u => u.Id == 1);
userName.Content = us.Name.ToString();
}
2
solved how to get one value from a table in the entity framework