static void Main(string[] args) { var ctx = new MongoContext("mongodb://localhost:27017/searchathing_patterns_mongoscopedchildren"); var repo = ctx.GetRepository <BaseDoc>(); { var filter = Builders <BaseDoc> .Filter.Empty; repo.Collection.DeleteMany(filter); } { var A = new BaseDoc(); A.Child = new ChildClass(A); repo.GenericInsert(ctx, A); } { var A = repo.Collection.AsQueryable().First(); A.Child.DoSomeJob(); } }
/// <summary> /// In this child SetScope will called from the ISupportInitialize root at EndInit(). /// </summary> public void SetScope(object root) { BaseDoc = root as BaseDoc; }
/// <summary> /// Constructor for run-time object allocation. /// </summary> public ChildClass(BaseDoc _BaseDoc) { BaseDoc = _BaseDoc; }