public virtual TProjection FirstOrDefault <TProjection>(TPrimaryKey id, Options.GetProjectedOptions <TEntity, TPrimaryKey, TProjection> options) where TProjection : class
        {
            IQueryable <TProjection> query = AsQueryable <TProjection>(
                projection: options?.Projection,
                predicate: CreateEqualityExpressionForId(id));

            return(query.FirstOrDefault());
        }
        public TProjection Get <TProjection>(TPrimaryKey id, Options.GetProjectedOptions <TEntity, TPrimaryKey, TProjection> options) where TProjection : class
        {
            var projection = FirstOrDefault <TProjection>(id, options);

            if (projection == null)
            {
                throw new EntityNotFoundException(typeof(TEntity), id);
            }

            return(projection);
        }
 public virtual Task <TProjection> FirstOrDefaultAsync <TProjection>(Expression <Func <TEntity, bool> > predicate, Options.GetProjectedOptions <TEntity, TPrimaryKey, TProjection> options) where TProjection : class
 {
     return(Task.FromResult(FirstOrDefault <TProjection>(predicate, options)));
 }
        public virtual TProjection FirstOrDefault <TProjection>(Expression <Func <TEntity, bool> > predicate, Options.GetProjectedOptions <TEntity, TPrimaryKey, TProjection> options) where TProjection : class
        {
            IQueryable <TProjection> query = AsQueryable <TProjection>(
                projection: options?.Projection,
                predicate: predicate);

            return(query.FirstOrDefault());
        }
 public virtual Task <TProjection> FirstOrDefaultAsync <TProjection>(TPrimaryKey id, Options.GetProjectedOptions <TEntity, TPrimaryKey, TProjection> options) where TProjection : class
 {
     return(Task.FromResult(FirstOrDefault <TProjection>(id, options)));
 }
        public TProjection Single <TProjection>(Expression <Func <TEntity, bool> > predicate, Options.GetProjectedOptions <TEntity, TPrimaryKey, TProjection> options) where TProjection : class
        {
            IQueryable <TProjection> query = AsQueryable <TProjection>(
                projection: options?.Projection,
                predicate: predicate);

            return(query.Single());
        }
        public virtual async Task <TProjection> GetAsync <TProjection>(TPrimaryKey id, Options.GetProjectedOptions <TEntity, TPrimaryKey, TProjection> options) where TProjection : class
        {
            var projection = await FirstOrDefaultAsync <TProjection>(id, options);

            if (projection == null)
            {
                throw new EntityNotFoundException(typeof(TEntity), id);
            }

            return(projection);
        }