Exemplo n.º 1
0
        /// <summary>
        /// Executes INSERT operation.
        /// </summary>
        /// <typeparam name="T">Type of the entity.</typeparam>
        /// <param name="queryEndpoint">The query endpoint.</param>
        /// <param name="evaluator">The expression, tha specify new values.</param>
        /// <returns>Key of the created entity.</returns>
        public static Key Insert <T>(this QueryEndpoint queryEndpoint, Expression <Func <T> > evaluator) where T : Entity
        {
            var operation = new InsertOperation <T>(queryEndpoint.Provider, evaluator);

            operation.Execute();
            return(operation.Key);
        }
        /// <summary>
        /// Asynchronously executes INSERT operation.
        /// </summary>
        /// <remarks>Multiple active operations in the same session instance are not supported. Use
        /// <see langword="await"/> to ensure that all asynchronous operations have completed before calling
        /// another method in this session.</remarks>
        /// <typeparam name="T">Type of the entity.</typeparam>
        /// <param name="queryEndpoint">The query endpoint.</param>
        /// <param name="evaluator">The expression, tha specify new values.</param>
        /// <param name="token">The cancellation token to terminate execution if necessary.</param>
        /// <returns>Key of the created entity.</returns>
        public static async Task <Key> InsertAsync <T>(this QueryEndpoint queryEndpoint, Expression <Func <T> > evaluator,
                                                       CancellationToken token = default) where T : Entity
        {
            var operation = new InsertOperation <T>(queryEndpoint.Provider, evaluator);
            await operation.ExecuteAsync(token).ConfigureAwait(false);

            return(operation.Key);
        }
        public CompiledQueryRunner(QueryEndpoint endpoint, object queryKey, object queryTarget)
        {
            session = endpoint.Provider.Session;
            domain  = session.Domain;

            this.endpoint    = endpoint;
            this.queryKey    = new Pair <object, string>(queryKey, session.StorageNodeId);
            this.queryTarget = queryTarget;
        }
Exemplo n.º 4
0
    private static IServiceCollection TryAddQueryEndpoint(
        this IServiceCollection services,
        QueryEndpoint queryEndpoint)
    {
        foreach (var service in services)
        {
            if (service.ServiceType == typeof(QueryEndpoint))
            {
                var endpoint = (QueryEndpoint)service.ImplementationInstance !;
                if (endpoint.Name == queryEndpoint.Name)
                {
                    return(services);
                }
            }
        }

        services.AddSingleton(queryEndpoint);
        return(services);
    }
Exemplo n.º 5
0
 private IQueryable <Invoice> GetFutureSequenceQueryFake(QueryEndpoint queryEndpoint)
 {
     return(null);
 }
Exemplo n.º 6
0
 private IQueryable <Invoice> GetFutureSequenceQuery(QueryEndpoint queryEndpoint)
 {
     return(Session.Demand().Query.All <Invoice>().Where(o => o.Commission > SearchedCommission));
 }
 private IQueryable <Customer> GetCustomers(ImpersonationContext context, QueryEndpoint query)
 {
     return(query.All <Customer>()
            .Where(c => c.Branch == Branch));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Starting point for every query for localizable entities.
 /// </summary>
 /// <typeparam name="TTarget">The type of the target.</typeparam>
 /// <typeparam name="TLocalization">The type of the localization.</typeparam>
 /// <returns></returns>
 public static IQueryable <LocalizationPair <TTarget, TLocalization> > All <TTarget, TLocalization>(this QueryEndpoint query) where TTarget : Entity where TLocalization : Localization <TTarget>
 {
     return(from target in query.All <TTarget>()
            join localization in query.All <TLocalization>()
            on target equals localization.Target
            where localization.CultureName == LocalizationContext.Current.CultureName
            select new LocalizationPair <TTarget, TLocalization>(target, localization));
 }
 private static IQueryable <VipCustomer> GetVipCustomers(ImpersonationContext context, QueryEndpoint query)
 {
     return(query.All <VipCustomer>().Where(v => v.Reason != "Relative"));
 }
 private static IQueryable <Customer> GetCustomers(ImpersonationContext context, QueryEndpoint query)
 {
     return(query.All <Customer>());
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SecureQueryRootBuilder"/> class.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <param name="origin">The original <see cref="QueryEndpoint"/> instance.</param>
 public SecureQueryRootBuilder(Session session, QueryEndpoint origin)
 {
     this.session  = session;
     InsecureQuery = origin;
 }
 private static IQueryable <Customer> GetCustomers(ImpersonationContext context, QueryEndpoint query)
 {
     return(query.All <Customer>()
            .Where(c => c.IsAutomobileIndustry));
 }
Exemplo n.º 13
0
        private static IQueryable <Customer> GetQuery(QueryEndpoint qe, string filter)
        {
            var customers = qe.All <Customer>().Where(cn => cn.CompanyName.StartsWith(filter));

            return(customers);
        }
 public FilteringRootBuilder(QueryEndpoint query)
 {
     this.query = query;
 }
Exemplo n.º 15
0
 private static IQueryable <Customer> GetCustomers(ImpersonationContext context, QueryEndpoint query)
 {
     return(query.All <Customer>()
            .Where(c => c.IsVip == false));
 }