public void PassAllParameters()
        {
            //ARRANGE
            var rowObject1 = TestDbTypeTable.Row1;

            var parameters = new[]
            {
                new SpecifiedParameter("BigInt", rowObject1.BigInt),
                new SpecifiedParameter("Binary50", rowObject1.Binary50),
                new SpecifiedParameter("Bit", rowObject1.Bit),
                new SpecifiedParameter("Char10", rowObject1.Char10),
                new SpecifiedParameter("Date", rowObject1.Date),
                new SpecifiedParameter("DateTime", rowObject1.DateTime),
                new SpecifiedParameter("DateTime2", rowObject1.DateTime2),
                new SpecifiedParameter("DateTimeOffset", rowObject1.DateTimeOffset),
                new SpecifiedParameter("Decimal", rowObject1.Decimal),
                new SpecifiedParameter("Float", rowObject1.Float),
                new SpecifiedParameter("Image", rowObject1.Image),
                new SpecifiedParameter("Int", rowObject1.Int),
                new SpecifiedParameter("Money", rowObject1.Money),
                new SpecifiedParameter("NChar10", rowObject1.NChar10),
                new SpecifiedParameter("NText", rowObject1.NText),
                new SpecifiedParameter("Numeric", rowObject1.Numeric),
                new SpecifiedParameter("NVarchar50", rowObject1.NVarchar50),
                new SpecifiedParameter("Real", rowObject1.Real),
                new SpecifiedParameter("SmallDateTime", rowObject1.SmallDateTime),
                new SpecifiedParameter("SmallInt", rowObject1.SmallInt),
                new SpecifiedParameter("SmallMoney", rowObject1.SmallMoney),
                new SpecifiedParameter("Text", rowObject1.Text),
                new SpecifiedParameter("Time", rowObject1.Time),
                new SpecifiedParameter("TinyInt", rowObject1.TinyInt),
                new SpecifiedParameter("Uniqueidentifier", rowObject1.Uniqueidentifier),
                new SpecifiedParameter("Varbinary50", rowObject1.Varbinary50),
                new SpecifiedParameter("Varchar50", rowObject1.Varchar50),
                new SpecifiedParameter("Xml", rowObject1.Xml)
            };

            var query = _queryFactory.CreateQuery();

            //ACT
            var result = query.Select <dynamic>(ExecuteProcQuery, parameters);

            //ASSERT
            AssertSingleDynamicObjectWithSingleRow(TestDbTypeTable.Row1, result);

            query.Dispose();
        }
        public void InvokeInTransaction_ShouldSaveData_WhenCommitTransaction()
        {
            //ARRANGE
            var query = _queryFactory.CreateQuery();

            //ACT
            query.BeginTransaction();
            query.Execute("create table #temp(id int)");
            query.Execute("insert into #temp(id) values(1)");
            query.CommitTransaction();

            //ASSERT
            int?id = query.Select <int?>("select id from #temp");

            Assert.AreEqual(1, id);

            query.Dispose();
        }
示例#3
0
        // APIs allowed to access the Auth server
        public static async Task <IEnumerable <ApiResource> > GetApiResources(IQueryFactory <ClientRegistration> clientRegistrationQueryFactory)
        {
            using (var query = clientRegistrationQueryFactory.CreateQuery())
            {
                var options = clientRegistrationQueryFactory.CreateQueryOptions();
                var clients = await query.Execute(options);

                return(clients.Select((clientRegistration) =>
                                      new ApiResource(clientRegistration.ScopeId, clientRegistration.ScopeName)
                                      ).Distinct().ToList());
            }
        }
示例#4
0
        public void PassAllParameters()
        {
            //ARRANGE
            var rowObject1 = TestDbTypeTable.Row1;
            var parameters = CreateDefiniedTypeFromRowObject(rowObject1);
            var query      = _queryFactory.CreateQuery();

            //ACT
            var result = query.Select <dynamic>(ExecuteProcQuery, parameters);

            //ASSERT
            AssertSingleDynamicObjectWithSingleRow(rowObject1, result);

            query.Dispose();
        }
示例#5
0
        public void PassAllParameters()
        {
            //ARRANGE
            var rowObject1 = TestDbTypeTable.Row1;

            var parameters = new object[]
            {
                rowObject1.BigInt,
                rowObject1.Binary50,
                rowObject1.Bit,
                rowObject1.Char10,
                rowObject1.Date,
                rowObject1.DateTime,
                rowObject1.DateTime2,
                rowObject1.DateTimeOffset,
                rowObject1.Decimal,
                rowObject1.Float,
                rowObject1.Image,
                rowObject1.Int,
                rowObject1.Money,
                rowObject1.NChar10,
                rowObject1.NText,
                rowObject1.Numeric,
                rowObject1.NVarchar50,
                rowObject1.Real,
                rowObject1.SmallDateTime,
                rowObject1.SmallInt,
                rowObject1.SmallMoney,
                rowObject1.Text,
                rowObject1.Time,
                rowObject1.TinyInt,
                rowObject1.Uniqueidentifier,
                rowObject1.Varbinary50,
                rowObject1.Varchar50,
                rowObject1.Xml
            };

            var query = _queryFactory.CreateQuery();

            //ACT
            var result = query.Select <dynamic>(ExecuteProcQuery, parameters);

            //ASSERT
            AssertSingleDynamicObjectWithSingleRow(TestDbTypeTable.Row1, result);

            query.Dispose();
        }
示例#6
0
        // Clients allowed to access resources from Auth Server
        public static async Task <IEnumerable <Client> > GetClients(IQueryFactory <ClientRegistration> clientRegistrationQueryFactory)
        {
            using (var query = clientRegistrationQueryFactory.CreateQuery())
            {
                var options = clientRegistrationQueryFactory.CreateQueryOptions();
                var clients = await query.Execute(options);

                return(clients.Select((clientRegistration) =>
                                      new Client
                {
                    ClientId = clientRegistration.ClientId,
                    AllowedGrantTypes = GrantTypes.ClientCredentials,
                    ClientSecrets =
                    {
                        new Secret(clientRegistration.ClientSecret.Sha256())
                    },
                    AllowedScopes = { clientRegistration.ScopeId }
                }
                                      ).ToList());
            }
        }
示例#7
0
        private IWindowView Deserialize(string persistString)
        {
            if (persistString.StartsWith(typeof(ImagesView).FullName))
            {
                var parts = persistString.Split(';');
                if (parts.Length == 1)
                {
                    var images = GetImages();
                    return(images.View);
                }
                else if (parts.Length == 2)
                {
                    // get the last query
                    var queryText = parts[1];
                    var query     = _queryCompiler.Compile(new StringReader(queryText), new NullQueryErrorListener());
                    if (query == null)
                    {
                        query = _queryFactory.CreateQuery();
                    }

                    var images = GetImages();
                    _dontShowImagesWindow = true;
                    try
                    {
                        _queryHistory.ExecuteQuery(query);
                    }
                    finally
                    {
                        _dontShowImagesWindow = false;
                    }

                    return(images.View);
                }
            }
            return(null);
        }
 private IQueryGenerator <T> BaseQuery <T>() where T : class
 {
     return(_queryFactory.CreateQuery <T>());
 }
 protected TQuery GetQuery <TQuery>() where TQuery : IQuery
 {
     return(_factory.CreateQuery <TQuery>());
 }
示例#10
0
        //----------------------------------------------------------------//

        public FeedManager(ISession session, IServiceProvider provider)
        {
            _commandFactory = provider.GetService <ICommandFactory>();
            _queryFactory   = provider.GetService <IQueryFactory>();

            _genreCommand      = _commandFactory.CreateCommand <IGenreCommand>(session);
            _companyCommand    = _commandFactory.CreateCommand <ICompanyCommand>(session);
            _countryCommand    = _commandFactory.CreateCommand <ICountryCommand>(session);
            _peopleCommad      = _commandFactory.CreateCommand <IPeopleCommand>(session);
            _movieCommand      = _commandFactory.CreateCommand <IMovieCommand>(session);
            _castCommand       = _commandFactory.CreateCommand <ICastCommand>(session);
            _crewCommand       = _commandFactory.CreateCommand <ICrewCommand>(session);
            _jobCommand        = _commandFactory.CreateCommand <IJobCommand>(session);
            _departmentCommand = _commandFactory.CreateCommand <IDepartmentCommand>(session);

            _movieGenreCommand   = _commandFactory.CreateCommand <IMovieGenreCommand>(session);
            _movieCompanyCommand = _commandFactory.CreateCommand <IMovieCompanyCommand>(session);
            _movieCountryCommand = _commandFactory.CreateCommand <IMovieCountryCommand>(session);

            _movieCountryQuery = _queryFactory.CreateQuery <IMovieCountryQuery>(session);
            _movieCompanyQuery = _queryFactory.CreateQuery <IMovieCompanyQuery>(session);
            _movieGenreQuery   = _queryFactory.CreateQuery <IMovieGenreQuery>(session);

            _movieQuery      = _queryFactory.CreateQuery <IMovieQuery>(session);
            _genreQuery      = _queryFactory.CreateQuery <IGenreQuery>(session);
            _companyQuery    = _queryFactory.CreateQuery <ICompanyQuery>(session);
            _countryQuery    = _queryFactory.CreateQuery <ICountryQuery>(session);
            _castQuery       = _queryFactory.CreateQuery <ICastQuery>(session);
            _crewQuery       = _queryFactory.CreateQuery <ICrewQuery>(session);
            _peopleQuery     = _queryFactory.CreateQuery <IPeopleQuery>(session);
            _jobQuery        = _queryFactory.CreateQuery <IJobQuery>(session);
            _departmentQuery = _queryFactory.CreateQuery <IDepartmentQuery>(session);

            _loadDataService = provider.GetRequiredService <ILoadDataService>();
        }
        public void PassAllParameters()
        {
            //ARRANGE
            var rowObject1 = TestDbTypeTable.Row1;

            var dataTable = new DataTable();

            dataTable.Columns.Add("BigInt", typeof(long));
            dataTable.Columns.Add("Binary50", typeof(byte[]));
            dataTable.Columns.Add("Bit", typeof(bool));
            dataTable.Columns.Add("Char10", typeof(string));
            dataTable.Columns.Add("Date", typeof(DateTime));
            dataTable.Columns.Add("DateTime", typeof(DateTime));
            dataTable.Columns.Add("DateTime2", typeof(DateTime));
            dataTable.Columns.Add("DateTimeOffset", typeof(DateTimeOffset));
            dataTable.Columns.Add("Decimal", typeof(decimal));
            dataTable.Columns.Add("Float", typeof(double));
            dataTable.Columns.Add("Image", typeof(byte[]));
            dataTable.Columns.Add("Int", typeof(int));
            dataTable.Columns.Add("Money", typeof(decimal));
            dataTable.Columns.Add("NChar10", typeof(string));
            dataTable.Columns.Add("NText", typeof(string));
            dataTable.Columns.Add("Numeric", typeof(decimal));
            dataTable.Columns.Add("NVarchar50", typeof(string));
            dataTable.Columns.Add("Real", typeof(float));
            dataTable.Columns.Add("SmallDateTime", typeof(DateTime));
            dataTable.Columns.Add("SmallInt", typeof(short));
            dataTable.Columns.Add("SmallMoney", typeof(decimal));
            dataTable.Columns.Add("Text", typeof(string));
            dataTable.Columns.Add("Time", typeof(TimeSpan));
            dataTable.Columns.Add("TinyInt", typeof(byte));
            dataTable.Columns.Add("Uniqueidentifier", typeof(Guid));
            dataTable.Columns.Add("Varbinary50", typeof(byte[]));
            dataTable.Columns.Add("Varchar50", typeof(string));
            dataTable.Columns.Add("Xml", typeof(string));

            dataTable.Rows.Add(new object[]
            {
                rowObject1.BigInt,
                rowObject1.Binary50,
                rowObject1.Bit,
                rowObject1.Char10,
                rowObject1.Date,
                rowObject1.DateTime,
                rowObject1.DateTime2,
                rowObject1.DateTimeOffset,
                rowObject1.Decimal,
                rowObject1.Float,
                rowObject1.Image,
                rowObject1.Int,
                rowObject1.Money,
                rowObject1.NChar10,
                rowObject1.NText,
                rowObject1.Numeric,
                rowObject1.NVarchar50,
                rowObject1.Real,
                rowObject1.SmallDateTime,
                rowObject1.SmallInt,
                rowObject1.SmallMoney,
                rowObject1.Text,
                rowObject1.Time,
                rowObject1.TinyInt,
                rowObject1.Uniqueidentifier,
                rowObject1.Varbinary50,
                rowObject1.Varchar50,
                rowObject1.Xml
            });

            var query = _queryFactory.CreateQuery();

            //ACT
            var result = query.Select <dynamic>(ExecuteProcQuery, dataTable);

            //ASSERT
            AssertSingleDynamicObjectWithSingleRow(TestDbTypeTable.Row1, result);

            query.Dispose();
        }
示例#12
0
        public void ExitSource(QueryParser.SourceContext context)
        {
            string viewIdentifier      = null;
            var    viewIdentifierToken = context.ID();

            if (viewIdentifierToken != null)
            {
                viewIdentifier = viewIdentifierToken.Symbol.Text;
            }
            else
            {
                viewIdentifierToken = context.COMPLEX_ID();
                if (viewIdentifierToken != null)
                {
                    viewIdentifier = ParseComplexIdentifier(viewIdentifierToken.Symbol);
                }
            }

            // create a query SELECT view
            if (viewIdentifier != null)
            {
                // if there is a cycle, report it and halt
                if (ReportCycle(
                        viewIdentifierToken.Symbol.Line,
                        viewIdentifierToken.Symbol.Column,
                        viewIdentifier))
                {
                    return;
                }

                // otherwise, compile the view
                var view = _compiler.Views.Find(viewIdentifier);
                if (view == null)
                {
                    ReportError(
                        viewIdentifierToken.Symbol.Line,
                        viewIdentifierToken.Symbol.Column,
                        $"Unknown view '{viewIdentifier}'");
                    return;
                }

                // compile view
                var query = _compiler.Compile(
                    new StringReader(view.Text),
                    _errorListener,
                    _parameters.Create(view.Name)) as IQuery;

                if (query == null) // compilation of the view failed
                {
                    HaltCompilation();
                    return;
                }

                _queries.Push(query.View(viewIdentifier));
            }
            else if (context.STRING() != null) // create a query SELECT pattern
            {
                var patternSymbol = context.STRING().Symbol;
                var pattern       = ParseStringValue(patternSymbol);

                try
                {
                    var query = _queryFactory.CreateQuery(pattern) as IQuery;
                    _queries.Push(query);
                }
                catch (ArgumentException) // invalid pattern
                {
                    ReportError(
                        patternSymbol.Line,
                        patternSymbol.Column,
                        $"Invalid path pattern: {pattern}");
                }
            }

            // otherwise, this is a subquery => it will push its own tree to the stack
        }
示例#13
0
 private void View_OpenDirectory(object sender, DirectoryEventArgs e)
 {
     _state.ExecuteQuery(_queryFactory.CreateQuery(e.FullPath));
 }