コード例 #1
0
 /// <summary>
 /// Read data
 /// </summary>
 /// <typeparam name="E">Type of data</typeparam>
 /// <param name="filter">Mongo filter</param>
 /// <param name="kit">Mongo kit</param>
 /// <returns>Mongo record</returns>
 public new E Get <E>(FilterDefinition <E> filter = null, MongoFilterKit kit = null) where E : IMongoEntityKeyable
 {
     // Read and return the data
     return(SyncKit.Run(() => base.Get(filter, kit)));
 }
コード例 #2
0
        /// <summary>
        /// Read data
        /// </summary>
        /// <typeparam name="E">Type of data</typeparam>
        /// <param name="filter">Mongo filter</param>
        /// <param name="kit">Mongo kit</param>
        /// <returns>Mongo records</returns>
        internal protected async Task <List <E> > Load <E>(FilterDefinition <E> filter = null, MongoFilterKit kit = null) where E : IMongoEntityKeyable
        {
            // Validating E
            MongoHelper.ValidateMongoEntity <E>();
            // Fixing filter
            filter ??= Builders <E> .Filter.Empty;
            // Fixing kit
            kit ??= new MongoFilterKit {
            };
            // Defining options according kit
            var options = kit.ToFindOptions <E>(Configuration.UseLowerCamelCaseProperties);
            // Generating data query
            var data = Session == null ?
                       await Collection <E>().FindAsync(filter, options) :
                       await Collection <E>().FindAsync(Session, filter, options);

            // Returning materialized data
            return(data.ToList());
        }
コード例 #3
0
        /// <summary>
        /// Read data
        /// </summary>
        /// <typeparam name="E">Type of data</typeparam>
        /// <param name="filter">Mongo filter</param>
        /// <param name="kit">Mongo kit</param>
        /// <returns>Mongo record</returns>
        internal protected async Task <E> Get <E>(FilterDefinition <E> filter = null, MongoFilterKit kit = null) where E : IMongoEntityKeyable
        {
            // Fixing kit
            kit ??= new MongoFilterKit {
            };
            kit.Limit = 1;
            // Loading data with only one record kit
            var data = await Load(filter, kit);

            // Returning that single record
            return(data.FirstOrDefault());
        }
コード例 #4
0
 /// <summary>
 /// Read data
 /// </summary>
 /// <typeparam name="E">Type of data</typeparam>
 /// <param name="filter">Mongo filter</param>
 /// <param name="kit">Mongo kit</param>
 /// <returns>Mongo record</returns>
 public new async Task <E> Get <E>(FilterDefinition <E> filter = null, MongoFilterKit kit = null) where E : IMongoEntityKeyable
 {
     // Read and return the data
     return(await base.Get(filter, kit));
 }