Example #1
0
        public DataStreamer(FileEntity parent)
        {
            this.parent = parent;
            parentType  = parent.GetType();

            db = TypeMap.GetDatabase(parentType);

            chunkCollection = db.GetCollection <FileChunk>(DB.CollectionName <FileChunk>());

            var dbName = db.DatabaseNamespace.DatabaseName;

            if (!indexedDBs.Contains(dbName))
            {
                indexedDBs.Add(dbName);

                _ = chunkCollection.Indexes.CreateOneAsync(
                    new CreateIndexModel <FileChunk>(
                        Builders <FileChunk> .IndexKeys.Ascending(c => c.FileID),
                        new CreateIndexOptions {
                    Background = true, Name = $"{nameof(FileChunk.FileID)}(Asc)"
                }));
            }
        }
 public DataStreamer(FileEntity parent)
 {
     this.parent = parent;
     var attribute = parent.GetType().GetCustomAttribute <DatabaseAttribute>(false);
     var dbName    = attribute != null ? attribute.Name : DB.GetInstance(default).dbName;