示例#1
0
        public LtConnectionTests()
        {
            var rand = new RandomEx(0);

            _container = new Container();

            _container.RegisterDelegate <IDbConnection>(() => new SqlConnectionFactory().Create(), reuse: Reuse.Scoped);

            new DryIoc.Module().Register(_container);
            var tableRegistrator = _container.Resolve <ITableDefinitionRegistrator>();

            tableRegistrator.Register(() => new NonRelationEntityDefinition());


            _entities = new SqlConnectionFactory().GetEntities();

            var tableResolver = _container.Resolve <ITableDefinitionResolver>();
            var dbConnection  = new SqlConnectionFactory().Create();
            var sqlBuilder    = new SQLiteSqlBuilder(tableResolver);

            _connection = new LtConnection(tableResolver, sqlBuilder, dbConnection);

            _allQuery    = new Query <NonRelationEntity>();
            _singleQuery = new Query <NonRelationEntity>(where : new EqualOperator(new Property <NonRelationEntity>(nameof(NonRelationEntity.Id)), new Parameter("Id")));
        }
示例#2
0
        public IEnumerable <NonRelationEntity> GetEntities()
        {
            var rand = new RandomEx(0);
            var id   = 1;

            yield return(new NonRelationEntity()
            {
                Id = id++, Code = rand.Next(), Name = rand.NextString()
            });

            yield return(new NonRelationEntity()
            {
                Id = id++, Code = rand.Next(), Name = rand.NextString()
            });

            yield return(new NonRelationEntity()
            {
                Id = id++, Code = rand.Next(), Name = rand.NextString()
            });
        }