Пример #1
0
        /// <summary>
        ///     Fetch the entity version and last modified time from the database
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public DocumentMetadata MetadataFor <T>(T entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var handler = new EntityMetadataQueryHandler(entity, _schema.StorageFor(typeof(T)),
                                                         _schema.MappingFor(typeof(T)));

            using (var connection = OpenConnection())
            {
                return(connection.Fetch(handler, null));
            }
        }
Пример #2
0
        /// <summary>
        ///     Fetch the entity version and last modified time from the database
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <DocumentMetadata> MetadataForAsync <T>(T entity, CancellationToken token = default(CancellationToken))
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var handler = new EntityMetadataQueryHandler(entity, _schema.StorageFor(typeof(T)),
                                                         _schema.MappingFor(typeof(T)));

            using (var connection = OpenConnection())
            {
                return(await connection.FetchAsync(handler, null, null, token).ConfigureAwait(false));
            }
        }