2019-12-30 04:35:54 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-01-01 16:19:06 +00:00
|
|
|
|
using System.Linq.Expressions;
|
2019-12-30 04:35:54 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-01-01 16:19:06 +00:00
|
|
|
|
using MongoDB.Driver;
|
|
|
|
|
using MongoDB.Driver.Linq;
|
2019-12-30 04:35:54 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.CacheServer
|
|
|
|
|
{
|
|
|
|
|
public static class Extensions
|
|
|
|
|
{
|
2020-01-01 16:19:06 +00:00
|
|
|
|
public static async Task<T> FindOneAsync<T>(this IMongoCollection<T> coll, Expression<Func<T, bool>> expr)
|
|
|
|
|
{
|
|
|
|
|
return (await coll.AsQueryable().Where(expr).Take(1).ToListAsync()).FirstOrDefault();
|
|
|
|
|
}
|
2019-12-30 04:35:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|