Sterling and Class hierarchy

Dec 7, 2010 at 2:41 PM
Edited Dec 7, 2010 at 2:41 PM

Hi there,

Is it possible in Sterling to use class hierarchies?

For example, I have class Principal and two derived classes Group and User.

Is is possible to make queries over Principal and get Group and User instances as a result?

Thank you in advance,


Dec 7, 2010 at 2:53 PM

Yes, Sterling will deal with the entire object graph.

Dec 7, 2010 at 3:12 PM
Edited Dec 7, 2010 at 3:15 PM

I just want to make sure, that you've got it properly.

public class Principal 
public Guid Id { get;set;}
  public string Name { get;set;}

public class Group: Principal
  public string GroupPermissions { get;set;}

public class User: Principal
  public string EMail { get;set;}

var id = Guid.NewGuid();
var id2 = Guid.NewGuid();

var userObj = new User { Id = id, Name = "Some Name", EMail = ""};
var groupObj = new Group { Id = id2, Name = "Group Name" };


var user = DatabaseService.Current.Database.Load<Principal>(id); // Should be of User class
var group = DatabaseService.Current.Database.Load<Principal>(id2); // Should be of Group class

Does Sterling work this way (table-based) or it is class-based?

Dec 9, 2010 at 1:16 PM

No, there is not a well-defined story for Sterling inferring the super type based on the class type. The save would work if you defined Principal as your table, I'm fairly certain, but Sterling doesn't encode the additional information to know to create a "User" or a "Group" coming back. This is a terrific feature request however and I'll add it to the list.