using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace CSH.Entity
{
[BsonIgnoreExtraElements]
public class User : BaseModel
{
public String email { get; set; }
public String mobile { get; set; }
public String password { get; set; }
public String organizationId { get; set; }
//@DBRef 这里是引用对象
//在数据为里存了$ref, $id,$db 字段
public Province province { get; set; }
}
}
public T GetModelById(string id)
{
try
{
//在这里希望能把整个对象查出来 ,包括:province 对象
return collection.Find(a => a.Id == new ObjectId(id).ToString()).FirstOrDefault();
}
catch (Exception ex)
{
Logger.Log(ex);
return null;
}
}
通过find方法希望能把整个对象查出来 ,包括:province 对象
https://segmentfault.com/q/1010000000622410
上面的文档解决不了。哪位大侠能帮忙看看。