/// <summary> /// Define a subdocument (or a list of) as a reference /// </summary> public EntityBuilder <T> DbRef <K>(Expression <Func <T, K> > property, string collection = null) { return(this.GetProperty(property, (p) => { BsonMapper.RegisterDbRef(_mapper, p, _typeNameBinder, collection ?? _mapper.ResolveCollectionName(typeof(K))); })); }
public LiteCollection(string name, LazyLoad <LiteEngine> engine, BsonMapper mapper, Logger log) { _name = name ?? mapper.ResolveCollectionName(typeof(T)); _engine = engine; _mapper = mapper; _log = log; _visitor = new QueryVisitor <T>(mapper); _includes = new List <string>(); // if strong typed collection, get _id member mapped (if exists) if (typeof(T) != typeof(BsonDocument)) { var entity = mapper.GetEntityMapper(typeof(T)); _id = entity.Id; if (_id != null && _id.AutoId) { _autoId = _id.DataType == typeof(ObjectId) ? BsonType.ObjectId : _id.DataType == typeof(Guid) ? BsonType.Guid : _id.DataType == typeof(DateTime) ? BsonType.DateTime : _id.DataType == typeof(Int32) ? BsonType.Int32 : _id.DataType == typeof(Int64) ? BsonType.Int64 : BsonType.Null; } } }
internal LiteCollection(string name, BsonAutoId autoId, ILiteEngine engine, BsonMapper mapper) { _collection = name ?? mapper.ResolveCollectionName(typeof(T)); _engine = engine; _mapper = mapper; _includes = new List <BsonExpression>(); // if strong typed collection, get _id member mapped (if exists) if (typeof(T) == typeof(BsonDocument)) { _entity = null; _id = null; _autoId = autoId; } else { _entity = mapper.GetEntityMapper(typeof(T)); _id = _entity.Id; if (_id != null && _id.AutoId) { _autoId = _id.DataType == typeof(Int32) || _id.DataType == typeof(Int32?) ? BsonAutoId.Int32 : _id.DataType == typeof(Int64) || _id.DataType == typeof(Int64?) ? BsonAutoId.Int64 : _id.DataType == typeof(Guid) || _id.DataType == typeof(Guid?) ? BsonAutoId.Guid : BsonAutoId.ObjectId; } else { _autoId = BsonAutoId.ObjectId; } } }
public LiteCollection(string name, LazyLoad <LiteEngine> engine, BsonMapper mapper, LoggerWrap log) { _name = name ?? mapper.ResolveCollectionName(typeof(T)); _engine = engine; _mapper = mapper; _log = log; _visitor = new QueryVisitor <T>(mapper); _includes = new List <Action <BsonDocument> >(); }