Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c60d9e0
Migrate to ESRP v5 (#1421)
habbes Feb 24, 2025
2730020
Add Obsolete attribute to EdmDeltaResourceObject and
gathogojr Mar 11, 2025
512b806
Merge pull request #1436 from OData/mark-delta-types-as-obsolete
gathogojr Mar 11, 2025
18a25ab
Fix regression causing navigation properties to be auto-expanded in t…
gathogojr Mar 12, 2025
ef3b1a5
Bump version to 9.2.1 (#1437)
gathogojr Mar 12, 2025
f44f6e0
Fix an issue where multiple flags are set and ensure correct deserial…
WanjohiSammy Mar 17, 2025
699f053
Fixes #1455 Add ISearchQueryValidator (#1456)
xuzhg Apr 10, 2025
74e5542
Restructure AggregationBinder and ComputeBinder for extensibility (po…
gathogojr Apr 16, 2025
7b71050
Bump version to 9.3.0 (#1464)
gathogojr Apr 16, 2025
6902fe5
Fix the typo of generaticType
xuzhg Apr 23, 2025
fc665bf
Fixes #580 Change PageResult<T> property names on serialization
xuzhg Apr 23, 2025
803a8f0
Fixes #1472: Custom ISearchBinder does not support deeply nested $exp…
xuzhg May 8, 2025
810dff5
Ensuring Url safe string key values. Aligning with ODL Client. Fixes …
uffelauesen May 8, 2025
2705588
CA2254 fixes possible formatting errors
Mar 27, 2025
90d911e
bump to release version 9.3.1
xuzhg May 13, 2025
fb45c0f
Enable minimal API OData (#1469)
xuzhg May 19, 2025
147abdf
Bump to version 9.4.0 preview
xuzhg May 19, 2025
4c2e572
Fixes #1483: Regression with computed in $orderby with 'Could not fin…
xuzhg Jun 5, 2025
8de6695
Fixes #1487 : Minimal API TimeZoneInfo for Serialization (#1488)
xuzhg Jun 17, 2025
c471502
Resolve the issue with IAsyncEnumerable (#1467)
WanjohiSammy Jun 18, 2025
a50f7f4
Resolve FormatException by escaping curly brackets and add tests for …
WanjohiSammy Jun 18, 2025
7c6fdbb
Fix vulnerable dependencies in newtonsoft.json (#1489)
WanjohiSammy Jun 18, 2025
0d971da
Fixes #1494: Enable DeltaSet<T> for minimal API parameter binding
xuzhg Jul 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions AspNetCoreOData.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ODataAlternateKeySample", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BenchmarkServer", "sample\BenchmarkServer\BenchmarkServer.csproj", "{8346AD1B-00E3-462D-B6B1-9AA3C2FB2850}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ODataMiniApi", "sample\ODataMiniApi\ODataMiniApi.csproj", "{53645862-60E1-403A-B9BB-911D3801010F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -75,6 +77,10 @@ Global
{8346AD1B-00E3-462D-B6B1-9AA3C2FB2850}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8346AD1B-00E3-462D-B6B1-9AA3C2FB2850}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8346AD1B-00E3-462D-B6B1-9AA3C2FB2850}.Release|Any CPU.Build.0 = Release|Any CPU
{53645862-60E1-403A-B9BB-911D3801010F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53645862-60E1-403A-B9BB-911D3801010F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53645862-60E1-403A-B9BB-911D3801010F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53645862-60E1-403A-B9BB-911D3801010F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -90,6 +96,7 @@ Global
{647EFCFA-55A7-4F0A-AD40-4B6EB1BFCFFA} = {B1F86961-6958-4617-ACA4-C231F95AE099}
{7B153669-A42F-4511-8BDB-587B3B27B2F3} = {B1F86961-6958-4617-ACA4-C231F95AE099}
{8346AD1B-00E3-462D-B6B1-9AA3C2FB2850} = {B1F86961-6958-4617-ACA4-C231F95AE099}
{53645862-60E1-403A-B9BB-911D3801010F} = {B1F86961-6958-4617-ACA4-C231F95AE099}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {540C9752-AAC0-49EA-BA60-78490C90FF86}
Expand Down
22 changes: 18 additions & 4 deletions pipelines/azure_pipelines_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ variables:
value: anycpu
- name: ProductBinPath
value: $(Build.SourcesDirectory)\bin\$(BuildPlatform)\$(BuildConfiguration)
- group: OData-ESRP-CodeSigning

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
Expand Down Expand Up @@ -125,10 +127,16 @@ extends:
displayName: Use .NET Core SDK 2.x
inputs:
version: 2.x
- task: EsrpCodeSigning@1
- task: EsrpCodeSigning@5
displayName: ESRP CodeSigning - WebAPI OData Product Signing
inputs:
ConnectedServiceName: 'ESRP CodeSigning - OData'
ConnectedServiceName: $(ODataEsrpConnectionServiceName)
AppRegistrationClientId: '$(ODataEsrpAppRegistrationClientId)'
AppRegistrationTenantId: '$(ODataEsrpAppRegistrationTenantId)'
AuthAKVName: $(ODataEsrpAuthAKVName)
AuthCertName: $(ODataEsrpAuthCertName)
AuthSignCertName: $(ODataEsrpAuthSignCertName)
ServiceEndpointUrl: '$(ODataEsrpServiceEndpointUrl)'
FolderPath: $(ProductBinPath)
Pattern: Microsoft.AspNetCore.OData.dll,Microsoft.AspNetCore.OData.NewtonsoftJson.dll
signConfigType: inlineSignParams
Expand Down Expand Up @@ -216,10 +224,16 @@ extends:
inputs:
command: custom
arguments: pack $(Build.SourcesDirectory)\src\Microsoft.AspNetCore.OData.NewtonsoftJson.Release.nuspec -NonInteractive -OutputDirectory $(Build.ArtifactStagingDirectory)\Nuget -Properties Configuration=$(BuildConfiguration);ProductRoot=$(ProductBinPath);SourcesRoot=$(Build.SourcesDirectory);VersionFullSemantic=$(VersionFullSemantic);NightlyBuildVersion=$(VersionNugetNightlyBuild);VersionNuGetSemantic=$(VersionNuGetSemantic) -Verbosity Detailed -Symbols -SymbolPackageFormat snupkg
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
- task: EsrpCodeSigning@5
displayName: ESRP CodeSigning - WebAPI OData Packages Signing
inputs:
ConnectedServiceName: ESRP CodeSigning - OData
ConnectedServiceName: $(ODataEsrpConnectionServiceName)
AppRegistrationClientId: '$(ODataEsrpAppRegistrationClientId)'
AppRegistrationTenantId: '$(ODataEsrpAppRegistrationTenantId)'
AuthAKVName: $(ODataEsrpAuthAKVName)
AuthCertName: $(ODataEsrpAuthCertName)
AuthSignCertName: $(ODataEsrpAuthSignCertName)
ServiceEndpointUrl: '$(ODataEsrpServiceEndpointUrl)'
FolderPath: $(Build.ArtifactStagingDirectory)\Nuget
Pattern: '*.nupkg'
signConfigType: inlineSignParams
Expand Down
180 changes: 180 additions & 0 deletions sample/ODataMiniApi/AppDb.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
//-----------------------------------------------------------------------------
// <copyright file="AppDb.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
// See License.txt in the project root for license information.
// </copyright>
//------------------------------------------------------------------------------

using Microsoft.EntityFrameworkCore;

namespace ODataMiniApi;

public class AppDb : DbContext
{
public AppDb(DbContextOptions<AppDb> options) : base(options) { }

public DbSet<School> Schools => Set<School>();

public DbSet<Student> Students => Set<Student>();

public DbSet<Customer> Customers => Set<Customer>();

public DbSet<Order> Orders => Set<Order>();

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<School>().HasKey(x => x.SchoolId);
modelBuilder.Entity<Student>().HasKey(x => x.StudentId);
modelBuilder.Entity<School>().OwnsOne(x => x.MailAddress);

modelBuilder.Entity<Customer>().HasKey(x => x.Id);
modelBuilder.Entity<Order>().HasKey(x => x.Id);
modelBuilder.Entity<Customer>().OwnsOne(x => x.Info);
}
}

static class AppDbExtension
{
public static void MakeSureDbCreated(this WebApplication app)
{
using (var scope = app.Services.CreateScope())
{
var services = scope.ServiceProvider;
var context = services.GetRequiredService<AppDb>();

if (context.Schools.Count() == 0)
{
#region Students
var students = new List<Student>
{
// Mercury school
new Student { SchoolId = 1, StudentId = 10, FirstName = "Spens", LastName = "Alex", FavoriteSport = "Soccer", Grade = 87, BirthDay = new DateOnly(2009, 11, 15) },
new Student { SchoolId = 1, StudentId = 11, FirstName = "Jasial", LastName = "Eaine", FavoriteSport = "Basketball", Grade = 45, BirthDay = new DateOnly(1989, 8, 3) },
new Student { SchoolId = 1, StudentId = 12, FirstName = "Niko", LastName = "Rorigo", FavoriteSport = "Soccer", Grade = 78, BirthDay = new DateOnly(2019, 5, 5) },
new Student { SchoolId = 1, StudentId = 13, FirstName = "Roy", LastName = "Rorigo", FavoriteSport = "Tennis", Grade = 67, BirthDay = new DateOnly(1975, 11, 4) },
new Student { SchoolId = 1, StudentId = 14, FirstName = "Zaral", LastName = "Clak", FavoriteSport = "Basketball", Grade = 54, BirthDay = new DateOnly(2008, 1, 4) },

// Venus school
new Student { SchoolId = 2, StudentId = 20, FirstName = "Hugh", LastName = "Briana", FavoriteSport = "Basketball", Grade = 78, BirthDay = new DateOnly(1959, 5, 6) },
new Student { SchoolId = 2, StudentId = 21, FirstName = "Reece", LastName = "Len", FavoriteSport = "Basketball", Grade = 45, BirthDay = new DateOnly(2004, 2, 5) },
new Student { SchoolId = 2, StudentId = 22, FirstName = "Javanny", LastName = "Jay", FavoriteSport = "Soccer", Grade = 87, BirthDay = new DateOnly(2003, 6, 5) },
new Student { SchoolId = 2, StudentId = 23, FirstName = "Ketty", LastName = "Oak", FavoriteSport = "Tennis", Grade = 99, BirthDay = new DateOnly(1998, 7, 25) },

// Earth School
new Student { SchoolId = 3, StudentId = 30, FirstName = "Mike", LastName = "Wat", FavoriteSport = "Tennis", Grade = 93, BirthDay = new DateOnly(1999, 5, 15) },
new Student { SchoolId = 3, StudentId = 31, FirstName = "Sam", LastName = "Joshi", FavoriteSport = "Soccer", Grade = 78, BirthDay = new DateOnly(2000, 6, 23) },
new Student { SchoolId = 3, StudentId = 32, FirstName = "Kerry", LastName = "Travade", FavoriteSport = "Basketball", Grade = 89, BirthDay = new DateOnly(2001, 2, 6) },
new Student { SchoolId = 3, StudentId = 33, FirstName = "Pett", LastName = "Jay", FavoriteSport = "Tennis", Grade = 63, BirthDay = new DateOnly(1998, 11, 7) },

// Mars School
new Student { SchoolId = 4, StudentId = 40, FirstName = "Mike", LastName = "Wat", FavoriteSport = "Soccer", Grade = 64, BirthDay = new DateOnly(2011, 11, 15) },
new Student { SchoolId = 4, StudentId = 41, FirstName = "Sam", LastName = "Joshi", FavoriteSport = "Basketball", Grade = 98, BirthDay = new DateOnly(2005, 6, 6) },
new Student { SchoolId = 4, StudentId = 42, FirstName = "Kerry", LastName = "Travade", FavoriteSport = "Soccer", Grade = 88, BirthDay = new DateOnly(2011, 5, 13) },

// Jupiter School
new Student { SchoolId = 5, StudentId = 50, FirstName = "David", LastName = "Padron", FavoriteSport = "Tennis", Grade = 77, BirthDay = new DateOnly(2015, 12, 3) },
new Student { SchoolId = 5, StudentId = 53, FirstName = "Jeh", LastName = "Brook", FavoriteSport = "Basketball", Grade = 69, BirthDay = new DateOnly(2014, 10, 15) },
new Student { SchoolId = 5, StudentId = 54, FirstName = "Steve", LastName = "Johnson", FavoriteSport = "Soccer", Grade = 100, BirthDay = new DateOnly(1995, 3, 2) },

// Saturn School
new Student { SchoolId = 6, StudentId = 60, FirstName = "John", LastName = "Haney", FavoriteSport = "Soccer", Grade = 99, BirthDay = new DateOnly(2008, 12, 1) },
new Student { SchoolId = 6, StudentId = 61, FirstName = "Morgan", LastName = "Frost", FavoriteSport = "Tennis", Grade = 17, BirthDay = new DateOnly(2009, 11, 4) },
new Student { SchoolId = 6, StudentId = 62, FirstName = "Jennifer", LastName = "Viles", FavoriteSport = "Basketball", Grade = 54, BirthDay = new DateOnly(1989, 3, 15) },

// Uranus School
new Student { SchoolId = 7, StudentId = 72, FirstName = "Matt", LastName = "Dally", FavoriteSport = "Basketball", Grade = 77, BirthDay = new DateOnly(2011, 11, 4) },
new Student { SchoolId = 7, StudentId = 73, FirstName = "Kevin", LastName = "Vax", FavoriteSport = "Basketball", Grade = 93, BirthDay = new DateOnly(2012, 5, 12) },
new Student { SchoolId = 7, StudentId = 76, FirstName = "John", LastName = "Clarey", FavoriteSport = "Soccer", Grade = 95, BirthDay = new DateOnly(2008, 8, 8) },

// Neptune School
new Student { SchoolId = 8, StudentId = 81, FirstName = "Adam", LastName = "Singh", FavoriteSport = "Tennis", Grade = 92, BirthDay = new DateOnly(2006, 6, 23) },
new Student { SchoolId = 8, StudentId = 82, FirstName = "Bob", LastName = "Joe", FavoriteSport = "Soccer", Grade = 88, BirthDay = new DateOnly(1978, 11, 15) },
new Student { SchoolId = 8, StudentId = 84, FirstName = "Martin", LastName = "Dalton", FavoriteSport = "Tennis", Grade = 77, BirthDay = new DateOnly(2017, 5, 14) },

// Pluto School
new Student { SchoolId = 9, StudentId = 91, FirstName = "Michael", LastName = "Wu", FavoriteSport = "Soccer", Grade = 97, BirthDay = new DateOnly(2022, 9, 22) },
new Student { SchoolId = 9, StudentId = 93, FirstName = "Rachel", LastName = "Wottle", FavoriteSport = "Soccer", Grade = 81, BirthDay = new DateOnly(2022, 10, 5) },
new Student { SchoolId = 9, StudentId = 97, FirstName = "Aakash", LastName = "Aarav", FavoriteSport = "Soccer", Grade = 98, BirthDay = new DateOnly(2003, 3, 15) },

// Shyline high School
new Student { SchoolId = 10, StudentId = 101, FirstName = "Steve", LastName = "Chu", FavoriteSport = "Soccer", Grade = 77, BirthDay = new DateOnly(2002, 11, 12) },
new Student { SchoolId = 10, StudentId = 123, FirstName = "Wash", LastName = "Dish", FavoriteSport = "Tennis", Grade = 81, BirthDay = new DateOnly(2002, 12, 5) },
new Student { SchoolId = 10, StudentId = 106, FirstName = "Ren", LastName = "Wu", FavoriteSport = "Soccer", Grade = 88, BirthDay = new DateOnly(2003, 3, 15) }
};

foreach (var s in students)
{
context.Students.Add(s);
}
#endregion

#region Schools
var schools = new List<School>
{
new School { SchoolId = 1, SchoolName = "Mercury Middle School", MailAddress = new Address { ApartNum = 241, City = "Kirk", Street = "156TH AVE", ZipCode = "98051" } },
new HighSchool { SchoolId = 2, SchoolName = "Venus High School", MailAddress = new Address { ApartNum = 543, City = "AR", Street = "51TH AVE PL", ZipCode = "98043" }, NumberOfStudents = 1187, PrincipalName = "Venus TT" },
new School { SchoolId = 3, SchoolName = "Earth University", MailAddress = new Address { ApartNum = 101, City = "Belly", Street = "24TH ST", ZipCode = "98029" } },
new School { SchoolId = 4, SchoolName = "Mars Elementary School ", MailAddress = new Address { ApartNum = 123, City = "Issaca", Street = "Mars Rd", ZipCode = "98023" } },
new School { SchoolId = 5, SchoolName = "Jupiter College", MailAddress = new Address { ApartNum = 443, City = "Redmond", Street = "Sky Freeway", ZipCode = "78123" } },
new School { SchoolId = 6, SchoolName = "Saturn Middle School", MailAddress = new Address { ApartNum = 11, City = "Moon", Street = "187TH ST", ZipCode = "68133" } },
new HighSchool { SchoolId = 7, SchoolName = "Uranus High School", MailAddress = new Address { ApartNum = 123, City = "Greenland", Street = "Sun Street", ZipCode = "88155" }, NumberOfStudents = 886, PrincipalName = "Uranus Sun" },
new School { SchoolId = 8, SchoolName = "Neptune Elementary School", MailAddress = new Address { ApartNum = 77, City = "BadCity", Street = "Moon way", ZipCode = "89155" } },
new School { SchoolId = 9, SchoolName = "Pluto University", MailAddress = new Address { ApartNum = 12004, City = "Sahamish", Street = "Universals ST", ZipCode = "10293" } },
new HighSchool { SchoolId =10, SchoolName = "Shyline High School", MailAddress = new Address { ApartNum = 4004, City = "Sammamish", Street = "8TH ST", ZipCode = "98029"}, NumberOfStudents = 976, PrincipalName = "Laly Fort" }
};

foreach (var s in schools)
{
s.Students = students.Where(std => std.SchoolId == s.SchoolId).ToList();

context.Schools.Add(s);
}
#endregion

context.SaveChanges();
}

if (context.Customers.Count() == 0)
{
#region Customers and Orders

var customers = new List<Customer>
{
new Customer { Id = 1, Name = "Alice", Info = new Info { Email = "[email protected]", Phone = "123-456-7819" },
Orders = [
new Order { Id = 11, Amount = 9},
new Order { Id = 12, Amount = 19},
] },
new Customer { Id = 2, Name = "Johnson", Info = new Info { Email = "[email protected]", Phone = "233-468-7289" },
Orders = [
new Order { Id = 21, Amount =8},
new Order { Id = 22, Amount = 76},
] },
new Customer { Id = 3, Name = "Peter", Info = new Info { Email = "[email protected]", Phone = "223-656-7889" },
Orders = [
new Order { Id = 32, Amount = 7 }
] },

new Customer { Id = 4, Name = "Sam", Info = new Info { Email = "[email protected]", Phone = "245-876-0989" },
Orders = [
new Order { Id = 41, Amount = 5 },
new Order { Id = 42, Amount = 32}
] }
};

foreach (var s in customers)
{
context.Customers.Add(s);
foreach (var o in s.Orders)
{
context.Orders.Add(o);
}
}
#endregion

context.SaveChanges();
}
}
}
}
109 changes: 109 additions & 0 deletions sample/ODataMiniApi/AppModels.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//-----------------------------------------------------------------------------
// <copyright file="AppModels.cs" company=".NET Foundation">
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
// See License.txt in the project root for license information.
// </copyright>
//------------------------------------------------------------------------------

using Microsoft.OData.Edm;
using Microsoft.OData.ModelBuilder;
using System.ComponentModel.DataAnnotations.Schema;

namespace ODataMiniApi;

public class EdmModelBuilder
{
public static IEdmModel GetEdmModel()
{
var builder = new ODataConventionModelBuilder();
builder.EntitySet<School>("Schools");
builder.ComplexType<Address>();
builder.ComplexType<Student>();

builder.EntitySet<Customer>("Customers");
builder.EntitySet<Order>("Orders");
builder.ComplexType<Info>();

var action = builder.EntityType<Customer>().Action("RateByName");
action.Parameter<string>("name");
action.Parameter<int>("age");
action.Returns<string>();

builder.EntityType<Customer>().Collection.Action("Rating").Parameter<int>("p");

return builder.GetEdmModel();
}
}

public class School
{
public int SchoolId { get; set; }

public string SchoolName { get; set; }

public Address MailAddress { get; set; }

public virtual IList<Student> Students { get; set; }
}

public class HighSchool : School
{
// Additional properties specific to HighSchool
public int NumberOfStudents { get; set; }
public string PrincipalName { get; set; }
}

public class Student
{
public int StudentId { get; set; }

public string FirstName { get; set; }

public string LastName { get; set; }

public string FavoriteSport { get; set; }

public int Grade { get; set; }

public int SchoolId { get; set; }

public DateOnly BirthDay { get; set; }
}

[ComplexType]
public class Address
{
public int ApartNum { get; set; }

public string City { get; set; }

public string Street { get; set; }

public string ZipCode { get; set; }
}


public class Customer
{
public int Id { get; set; }

public string Name { get; set; }

public Info Info { get; set; }

//[AutoExpand]
public List<Order> Orders { get; set; }
}

public class Order
{
public int Id { get; set; }

public int Amount { get; set; }
}

public class Info
{
public string Email { get; set; }
public string Phone { get; set; }
}
Loading
Loading