Is there any way to order a query by a property that isn't stored in Raven (as I write this, it sounds pretty obvious that Raven can't query something it doesn't know about)?
What I'm trying to do is sort by the numeric ID instead of the full string ID. I have an Id property on my model that is the full string ID (e.g. "users/123"), and then a property called UserId that parses out just the integer value from the string ID (e.g. 123). How can I sort by the UserId? Right now it's decorated with [JsonIgnore] so that it doesn't get stored (it feels like storing duplicate data, so I didn't want to store it). Do I need to actually store it in order to sort by it?
Here is my User model:
public class User
{
public User()
{
Status = UserStatus.Active;
}
public string Id { get; set; }
[JsonIgnore]
public int UserId
{
get
{
int userId;
int.TryParse(Id.Replace("users/", ""), out userId);
return userId;
}
}
public string Username { get; set; }
public string Password { get; set; }
public string Email { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Location { get; set; }
public bool OptIn { get; set; }
public DateTime LastActivity { get; set; }
public UserStatus Status { get; set; }
public bool IsDeleted { get; set; }
public string[] RoleIds { get; set; }
[JsonIgnore]
public string FullName
{
get {
return !string.IsNullOrEmpty(FirstName) || !string.IsNullOrEmpty(LastName)
? string.Format("{0} {1}", FirstName, LastName)
: null;
}
}
}