public Database(string connectionString) { cli = new MongoClient(connectionString); db = cli.GetServer().GetDatabase("autoru"); CachedContent.EnsureIndex(IndexKeys <CachedContent> .Descending(x => x.Timestamp), IndexOptions.SetTimeToLive(TimeSpan.FromDays(7))); Post.EnsureIndex(IndexKeys <Post> .Descending(x => x.Timestamp), IndexOptions.SetTimeToLive(TimeSpan.FromDays(7))); Post.EnsureIndex(IndexKeys <Post> .Ascending(x => x.ForumId) .Descending(x => x.TopicId) .Ascending(x => x.Index) ); if (!Forum.AsQueryable().Any()) { Forum.Save(new Forum { ForumId = "moto", DoCrawl = true }); Forum.Save(new Forum { ForumId = "scooter", DoCrawl = true }); } User.EnsureIndex(IndexKeys <User> .Ascending(x => x.UserName)); ReadId.EnsureIndex(IndexKeys <ReadId> .Ascending(x => x.UserId).Ascending(x => x.PostId)); ReadId.EnsureIndex(IndexKeys <ReadId> .Ascending(x => x.UserId).Descending(x => x.Timestamp)); }