Ejemplo n.º 1
0
        public void Create_Ignores_Server_Generated_Primary_Keys()
        {
            var schema = new SchemaBuilder()
                         .Define <ServerPrimaryKey>()
                         .Build();
            var entity = new ServerPrimaryKey();
            var query  = InsertBuilder <ServerPrimaryKey> .Create(schema, entity)
                         .BuildQuery() as InsertExpression;

            Assert.AreEqual(0, query.Columns.Length);
            Assert.AreEqual(1, query.RowsExpressions.Length);
            Assert.AreEqual(0, query.RowsExpressions[0].Length);
        }
Ejemplo n.º 2
0
        public void Create_From_View_Returns_Entity_Insert()
        {
            var schema = new SchemaBuilder()
                         .Define <SimpleEntity>()
                         .Build();
            var entity = new { Property = "1234" };
            var query  = InsertBuilder <SimpleEntity> .Create(schema, entity)
                         .BuildQuery() as InsertExpression;

            Assert.IsNotNull(query);
            Assert.AreEqual("SimpleEntity", query.Table.TableName);
            Assert.AreEqual(1, query.Columns.Length);
            Assert.AreEqual("Property", query.Columns[0].ColumnName);
            Assert.AreEqual(1, query.RowsExpressions.Length);
            Assert.AreEqual(1, query.RowsExpressions[0].Length);
            Assert.AreEqual(entity.Property, ((ValueExpression)query.RowsExpressions[0][0]).Value);
        }
Ejemplo n.º 3
0
        public void Create_View_Maps_Converted_Fields()
        {
            var schema = new SchemaBuilder()
                         .Define <EntityModel>()
                         .AddTypeConverters(new[] { new SubConverter() })
                         .Build();
            var view = new ViewModel
            {
                Sub = new ViewModelSub {
                    CustomData = "Hello World"
                }
            };
            var query = InsertBuilder <EntityModel> .Create(schema, view)
                        .BuildQuery() as InsertExpression;

            Assert.IsNotNull(query);
            Assert.IsTrue(query.Columns.Any(q => q.ColumnName == "Sub_Data"));
            var valueExpr = query.RowsExpressions[0][0] as ValueExpression;

            Assert.AreEqual(view.Sub.CustomData, valueExpr.Value);
        }
Ejemplo n.º 4
0
 public IEntityInsertQueryBuilder <T> Insert <TView>(TView entityView) where TView : class
 => InsertBuilder <T> .Create(_schema, _entityModel, entityView);
Ejemplo n.º 5
0
 public IEntityInsertQueryBuilder <T> Insert(T entity)
 => InsertBuilder <T> .Create(_schema, _entityModel, entity);