This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"> | |
<edmx:DataServices> | |
<Schema Namespace="ODataApiVersion.Models.v1" xmlns="http://docs.oasis-open.org/odata/ns/edm"> | |
<EntityType Name="Customer"> | |
<Key> | |
<PropertyRef Name="Id" /> | |
</Key> | |
<Property Name="Name" Type="Edm.String" /> | |
<Property Name="PhoneNumber" Type="Edm.String" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"@odata.context":"http://localhost:5001/odata/$metadata#Books(ISBN,Location,Press(Name))", | |
"value":[ | |
{ | |
"ISBN":"063-6-920-02371-5", | |
"Location":{ | |
"Street":"Main ST" | |
}, | |
"Press":{ | |
"Name":"O'Reilly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"@odata.context":"http://localhost:5001/odata/$metadata#Books/$entity", | |
"Id":2, | |
"ISBN":"063-6-920-02371-5", | |
"Title":"Enterprise Games", | |
"Author":"Michael Hugos", | |
"Price":49.99, | |
"Location":{ | |
"City":"Bellevue", | |
"Street":"Main ST" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
app.UseRouting(); | |
app.UseEndpoints(endpoints => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddDbContext<BookStoreContext>(opt => opt.UseInMemoryDatabase("BookLists")); | |
services.AddControllers(); | |
services.AddOData(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk.Web"> | |
<PropertyGroup> | |
<TargetFramework>netcoreapp5.0</TargetFramework> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.4.0-beta" /> | |
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.0-preview.2.20159.4" /> | |
</ItemGroup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk.Web"> | |
<PropertyGroup> | |
<TargetFramework>netcoreapp2.1</TargetFramework> | |
</PropertyGroup> | |
<ItemGroup> | |
<Folder Include="wwwroot\" /> | |
</ItemGroup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BookStoreContext : DbContext | |
{ | |
public BookStoreContext(DbContextOptions<BookStoreContext> options) | |
: base(options) | |
{ | |
} | |
public DbSet<Book> Books { get; set; } | |
public DbSet<Press> Presses { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
// ... | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddDbContext<BookStoreContext>(opt => opt.UseInMemoryDatabase("BookLists")); | |
services.AddOData(); | |
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DataSource | |
{ | |
private static IList<Book> _books { get; set; } | |
public static IList<Book> GetBooks() | |
{ | |
if (_books != null) | |
{ | |
return _books; | |
} |
NewerOlder