Initial Commit ...
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MongoDB.Driver;
|
||||
using MongoDB.Driver.Linq;
|
||||
using xModels.Base;
|
||||
|
||||
namespace xDataService.Mongo {
|
||||
public class XMongoQueryable<TEntity, TKey> : IMongoQueryable<TEntity>
|
||||
where TEntity : XBaseEntity<TKey> {
|
||||
private readonly IMongoCollection<TEntity> collection;
|
||||
|
||||
public Type ElementType { get; }
|
||||
public IQueryable<TEntity> Items { get; }
|
||||
public Expression Expression { get; }
|
||||
public IQueryProvider Provider { get; }
|
||||
|
||||
public XMongoQueryable (
|
||||
IQueryable<TEntity> items,
|
||||
IMongoCollection<TEntity> collection
|
||||
) {
|
||||
//
|
||||
this.Items = items;
|
||||
this.collection = collection;
|
||||
|
||||
//
|
||||
Provider = items.Provider;
|
||||
Expression = items.Expression;
|
||||
ElementType = items.ElementType;
|
||||
}
|
||||
|
||||
public IEnumerator<TEntity> GetEnumerator () {
|
||||
return Items.GetEnumerator ();
|
||||
}
|
||||
|
||||
public QueryableExecutionModel GetExecutionModel () {
|
||||
return collection.AsQueryable ().GetExecutionModel ();
|
||||
}
|
||||
|
||||
public IAsyncCursor<TEntity> ToCursor (CancellationToken cancellationToken = default) {
|
||||
return new XMongoAsyncCursor<TEntity> (Items);
|
||||
}
|
||||
|
||||
public Task<IAsyncCursor<TEntity>> ToCursorAsync (CancellationToken cancellationToken = default) {
|
||||
return Task.Run (() => new XMongoAsyncCursor<TEntity> (Items) as IAsyncCursor<TEntity>);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator () {
|
||||
return Items.GetEnumerator ();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user