public void GetEdmModel_WorksOnModelBuilder_WithDateTime() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfiguration <DateTimeModel> entity = builder.EntityType <DateTimeModel>(); entity.HasKey(c => c.BirthdayA); entity.Property(c => c.BirthdayB); entity.CollectionProperty(c => c.BirthdayC); entity.CollectionProperty(c => c.BirthdayD); // Act IEdmModel model = builder.GetEdmModel(); // Assert Assert.NotNull(model); IEdmEntityType entityType = Assert.Single(model.SchemaElements.OfType <IEdmEntityType>()); Assert.Equal("BirthdayA", entityType.DeclaredKey.Single().Name); IList <IEdmProperty> properties = entityType.Properties().ToList(); Assert.Equal(4, properties.Count); Assert.Equal("BirthdayA", properties[0].Name); Assert.Equal("BirthdayB", properties[1].Name); Assert.Equal("BirthdayC", properties[2].Name); Assert.Equal("BirthdayD", properties[3].Name); }
public static IEdmModel GetExplicitModel() { ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfiguration <Window> windowType = builder.EntityType <Window>(); windowType.HasKey(a => a.Id); windowType.Property(a => a.Name).IsRequired(); windowType.ComplexProperty(w => w.CurrentShape).IsNullable(); windowType.CollectionProperty(w => w.OptionalShapes); windowType.CollectionProperty(w => w.PolygonalShapes); windowType.HasOptional <Window>(w => w.Parent); ComplexTypeConfiguration <Shape> shapeType = builder.ComplexType <Shape>(); shapeType.Property(s => s.HasBorder); shapeType.Abstract(); ComplexTypeConfiguration <Circle> circleType = builder.ComplexType <Circle>(); circleType.ComplexProperty(c => c.Center); circleType.Property(c => c.Radius); circleType.DerivesFrom <Shape>(); ComplexTypeConfiguration <Polygon> polygonType = builder.ComplexType <Polygon>(); polygonType.CollectionProperty(p => p.Vertexes); polygonType.DerivesFrom <Shape>(); ComplexTypeConfiguration <Rectangle> rectangleType = builder.ComplexType <Rectangle>(); rectangleType.ComplexProperty(r => r.TopLeft); rectangleType.Property(r => r.Width); rectangleType.Property(r => r.Height); rectangleType.DerivesFrom <Polygon>(); ComplexTypeConfiguration <Point> pointType = builder.ComplexType <Point>(); pointType.Property(p => p.X); pointType.Property(p => p.Y); EntitySetConfiguration <Window> windows = builder.EntitySet <Window>("Windows"); // windows.HasEditLink(link, true); // windows.HasIdLink(link, true); windows.HasOptionalBinding(c => c.Parent, "Windows"); builder.Namespace = typeof(Window).Namespace; return(builder.GetEdmModel()); }