public void Join_double() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .Join( ctx.Things, ctx.Owning, (w) => w, (t) => t, (w, t, r) => new { w, t, r } ) .Join( ctx.Persons, ctx.Supervising, (o) => o.w, (p) => p, (o, p, r) => new { o, p, r } ) .AsCypher(); Assert.Equal( "MATCH (w:Warehouse)\r\nMATCH (w)-[r:\"OWNS\"]->(t:Thing)\r\nMATCH (w)-[r0:\"Supervise\"]->(p:Person) RETURN \"w\".\"Location\", \"w\".\"Size\", \"r\".\"Partial\", \"t\".\"Number\", \"r0\".\"Certified\", \"p\".\"Name\"", cypher ); } }
public void Storage() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var Location = ctx.Model .FindEntityType(typeof(Warehouse)) .FindProperty("Location"); var me = new StorageExpression( "Place", Location, new NodePatternExpression( new string[] { "Warehouse" }, null, "w" ) ); var other = new StorageExpression( "Place", Location, new NodePatternExpression( new string[] { "Warehouse" }, null, "w" ) ); Assert.True(comparer.Equals(me, other)); } }
public void Select_warehouse_without_linq() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .AsCypher(); Assert.Equal( "MATCH (w:Warehouse) RETURN \"w\".\"Location\", \"w\".\"Size\"", cypher ); } }
public void Select_warehouse_with_empty() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .Select(w => new { }) .AsCypher(); Assert.Equal( "MATCH (w:Warehouse) RETURN 1", cypher ); } }
public void Select_warehouse_with_nested() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .Select(w => new { w.Location, Size = new { w.Size } }) .AsCypher(); Assert.Equal( "MATCH (w:Warehouse) RETURN \"w\".\"Location\", \"w\".\"Size\"", cypher ); } }
public void Select_warehouse_with_object() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .Select(w => new { Place = w.Location, Status = 1 }) .AsCypher(); Assert.Equal( "MATCH (w:Warehouse) RETURN \"w\".\"Location\" AS \"Place\"", cypher ); } }
public void Where_single_property_equal() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .Where(w => w.Size == 100) .AsCypher(); Assert.Equal( "MATCH (w:Warehouse)\r\nWHERE \"w\".\"Size\" = 100 RETURN \"w\".\"Location\", \"w\".\"Size\"", cypher ); } }
public void Select_warehouse_with_conditional_case() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .Select(w => new { IsBig = w.Size > 100 ? "Giant" : "Ant" }) .AsCypher(); Assert.Equal( "MATCH (w:Warehouse) RETURN CASE\r\n WHEN \"w\".\"Size\" > 100\r\n THEN 'Giant' ELSE 'Ant'\r\nEND AS \"IsBig\"", cypher ); } }
public void Select_warehouse_with_conditional() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .Select(w => new { IsBig = w.Size > 100 }) .AsCypher(); Assert.Equal( "MATCH (w:Warehouse) RETURN \"w\".\"Size\" > 100 AS \"IsBig\"", cypher ); } }
public void SelectMany_single() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .SelectMany( w => ctx.Persons, (w, p) => new { w, p } ) .AsCypher(); Assert.Equal( "MATCH (w:Warehouse)\r\nMATCH (p:Person) RETURN \"w\".\"Location\", \"w\".\"Size\", \"p\".\"Name\"", cypher ); } }
public void Join_simple_projection() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .Join( ctx.Things, ctx.Owning, (w) => w, (t) => t, (w, t, r) => t ) .AsCypher(); Assert.Equal( "MATCH (w:Warehouse)\r\nMATCH (w)-[r:\"OWNS\"]->(t:Thing) RETURN \"t\".\"Number\"", cypher ); } }
public void Join_single() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .Join( ctx.Things, ctx.Owning, (o) => o, (i) => i, (o, i, r) => new { o, i, r } ) .AsCypher(); Assert.Equal( "MATCH (o:Warehouse)\r\nMATCH (o)-[r:\"OWNS\"]->(i:Thing) RETURN \"o\".\"Location\", \"o\".\"Size\", \"r\".\"Partial\", \"i\".\"Number\"", cypher ); } }
public void Join_select_many() { using (var ctx = new CypherFaceDbContext(DbContextOptions)) { var cypher = ctx.Warehouses .Join( ctx.Things, ctx.Owning, (w) => w, (t) => t, (w, t, r) => new { w, r } ) .SelectMany( x => ctx.Persons, (x, p) => new { x, p } ) .AsCypher(); Assert.Equal( "MATCH (w:Warehouse)\r\nMATCH (w)-[r:\"OWNS\"]->(t:Thing)\r\nMATCH (p:Person) RETURN \"w\".\"Location\", \"w\".\"Size\", \"r\".\"Partial\", \"p\".\"Name\"", cypher ); } }