Skip to content

Commit

Permalink
Add a README to NuGet package (#1368)
Browse files Browse the repository at this point in the history
* Add README.md to Package
  • Loading branch information
WanjohiSammy authored Dec 9, 2024
1 parent b042413 commit d0b2f76
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ This is the official ASP.NET Core OData repository.

* [ASP.NET Core OData 8.0 Preview for .NET 5](https://devblogs.microsoft.com/odata/asp-net-odata-8-0-preview-for-net-5/)


#### **Documentation**:

For comprehensive documentation, please refer to the following links:
- [ASP.NET Core OData Overview](https://learn.microsoft.com/odata/webapi-8/overview)
- [Getting Started](https://learn.microsoft.com/odata/webapi-8/getting-started)
- [Fundamentals Overview](https://learn.microsoft.com/odata/webapi-8/fundamentals/overview)
- [Tutorials](https://learn.microsoft.com/odata/webapi-8/tutorials/basic-crud)
- [OData Dev Blogs](https://devblogs.microsoft.com/odata/)
- [OData.org](https://www.odata.org/blog/)

**Example**:
* [ODataRoutingSample](https://github.com/OData/AspNetCoreOData/tree/main/sample/ODataRoutingSample): ASP.NET Core OData sample project in this repo.

Expand All @@ -47,9 +58,20 @@ This is the official ASP.NET Core OData repository.
* [AspNetCoreOData.NewtonsoftJson.sln](AspNetCoreOData.NewtonsoftJson.sln)

- Includes **Microsoft.AspNetCore.OData.NewtonsoftJson** project, Unit Test, E2E Test & Samples

## 2. Basic Usage

### Microsoft.AspNetCore.OData Package Installation
Using .NET CLI:
```bash
dotnet add package Microsoft.AspNetCore.OData
```

Using Package Manager:
```bash
Install-Package Microsoft.AspNetCore.OData
```

In the ASP.NET Core Web Application project, update your `Startup.cs` as below:

```C#
Expand Down Expand Up @@ -80,6 +102,35 @@ public class Startup
}
```

If you work with `Program.cs`, update as below. Refer to the [Getting Started Guide](https://learn.microsoft.com/odata/webapi-8/getting-started).
```c#
// using statements
var builder = WebApplication.CreateBuilder(args);

var modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntityType<Order>();
modelBuilder.EntitySet<Customer>("Customers");

builder.Services.AddControllers().AddOData(
options => options.Select().Filter().OrderBy().Expand().Count().SetMaxTop(null).AddRouteComponents(
"odata",
GetEdmModel()));

var app = builder.Build();

app.UseRouting();

app.MapControllers();

app.Run();

static IEdmModel GetEdmModel()
{
//
}
```

That's it.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Microsoft.AspNetCore.OData</RootNamespace>
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
<!-- Let's generate our own assembly info -->
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand Down Expand Up @@ -70,6 +71,10 @@
<AdditionalFiles Include="PublicAPI.Unshipped.txt" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>
Expand Down

0 comments on commit d0b2f76

Please sign in to comment.