我想知道使用引用进行建模的最佳实践是什么情况.我正在使用MongoRepository库.
public class User : Entity
{
publis string Id { get; set; }
public string Email { get; set; }
public string Password { get; set; }
}
public class Post : Entity
{
public string Id { get; set; }
public string Title { get; set; }
public string Summary { get; set; }
public DateTime Added { get; set; }
public User Owner { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
存储帖子时我只想引用所有者(用户)对象而不是整个对象底层.
目前我这样做,不知道更好的方式......
var post = new Post …Run Code Online (Sandbox Code Playgroud)