// Executes the expression tree that is passed to it.
        internal static object Execute(Expression expression, bool isEnumerable, LinqToAzureInputs inputs)
        {
            // The expression must represent a query over the data source.
            if (!IsQueryOverDataSource(expression))
                throw new InvalidProgramException("No query over the data source was specified.");

            // Find the call to Where() and get the lambda expression predicate.
            var factory = new ExecutionFactory(expression, inputs);
            var queryableStorageAccount = factory.GetConcreteQueryable();

            // Copy the expression tree that was passed in, changing only the first
            // argument of the innermost MethodCallExpression.
            var treeCopier = new ExpressionTreeModifier(queryableStorageAccount);
            var newExpressionTree = treeCopier.Visit(expression);

            // This step creates an IQueryable that executes by replacing Queryable methods with Enumerable methods.
            return isEnumerable ? queryableStorageAccount.Provider.CreateQuery(newExpressionTree) : queryableStorageAccount.Provider.Execute(newExpressionTree);
        }
예제 #2
0
        // Executes the expression tree that is passed to it.
        internal static object Execute(Expression expression, bool isEnumerable, LinqToAzureInputs inputs)
        {
            // The expression must represent a query over the data source.
            if (!IsQueryOverDataSource(expression))
            {
                throw new InvalidProgramException("No query over the data source was specified.");
            }

            // Find the call to Where() and get the lambda expression predicate.
            var factory = new ExecutionFactory(expression, inputs);
            var queryableStorageAccount = factory.GetConcreteQueryable();

            // Copy the expression tree that was passed in, changing only the first
            // argument of the innermost MethodCallExpression.
            var treeCopier        = new ExpressionTreeModifier(queryableStorageAccount);
            var newExpressionTree = treeCopier.Visit(expression);

            // This step creates an IQueryable that executes by replacing Queryable methods with Enumerable methods.
            return(isEnumerable ? queryableStorageAccount.Provider.CreateQuery(newExpressionTree) : queryableStorageAccount.Provider.Execute(newExpressionTree));
        }
예제 #3
0
 /// <summary>
 /// This constructor is called by the client to create the data source.
 /// </summary>
 public LinqToAzureOrderedQueryable(LinqToAzureInputs inputs)
 {
     Provider   = new LinqToAzureQueryableProvider(inputs);
     Expression = Expression.Constant(this);
 }
 /// <summary>
 /// Used to construct an ExecutionFactory
 /// </summary>
 /// <param name="expression">The expression reduced from the query</param>
 /// <param name="inputs">The inputs to Windows Azure</param>
 public ExecutionFactory(Expression expression, LinqToAzureInputs inputs)
 {
     _expression = expression;
     _inputs = inputs;
 }
        /// <summary>
        /// Adds IP addresses to the WASD firewall for a 
        /// </summary>
        public void AddIpsToSqlFirewallFromCloudService(string cloudServiceName, bool removeAllOtherRules = true, DeploymentSlot slot = DeploymentSlot.Production)
        {
            if(ServerName == null)
                throw new FluentManagementException("unable to continue without windows azure sql database server name", "SqlDatabaseClient");

            if (removeAllOtherRules)
            {
                // get these rules
                var command = new ListFirewallRulesCommand(ServerName)
                    {
                        SubscriptionId = _subscriptionId,
                        Certificate = _managementCertificate
                    };
                command.Execute();
                foreach (var rule in command.FirewallRules)
                {
                    var ruleCommand = new DeleteSqlFirewallRuleCommand(ServerName, rule.RuleName)
                        {
                            SubscriptionId = _subscriptionId,
                            Certificate = _managementCertificate
                        };
                    ruleCommand.Execute();
                }
            }

            var inputs = new LinqToAzureInputs()
            {
                ManagementCertificateThumbprint = _managementCertificate.Thumbprint,
                SubscriptionId = _subscriptionId
            };
            // build up a filtered query to check the new account
            var cloudServiceQueryable = new LinqToAzureOrderedQueryable<CloudService>(inputs);
            // get only production deployments
            var query = from service in cloudServiceQueryable
                        where service.Deployments.Count != 0
                        && service.Deployments.Any(a => a.Slot == slot)
                        select service;
            var cloudService = query.First();
            // enumerate the cloud service deployment and add the ips to the database firewall
            var addRuleCommand = new AddNewFirewallRuleCommand(cloudServiceName,
                                                               cloudService.Deployments.First().RoleInstances.First().VirtualIpAddress,
                                                               cloudService.Deployments.First().RoleInstances.First().VirtualIpAddress)
                {
                    SubscriptionId = _subscriptionId,
                    Certificate = _managementCertificate
                };
            addRuleCommand.ConfigureFirewallCommand(ServerName);
            addRuleCommand.Execute();
        }
 public LinqToAzureQueryableProvider(LinqToAzureInputs inputs)
 {
     SubscriptionInformation = inputs;
 }