public class Product { public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } [SchemaMethod] public decimal DiscountedPrice() { const decimal discount = 0.1m; return Price * (1 - discount); } }
public class Order { public int Id { get; set; } public string CustomerName { get; set; } public ListIn this example, the PlaceOrder method is marked with the [SchemaMethod] attribute. This tells the OData builder to generate an OData action that can be used to place an order. Both of these examples use SchemaMethod to define custom functionality for OData entities that is not directly mapped to their properties. The Microsoft.AspNet.OData package library provides many other classes and features for building OData APIs in .NET.Products { get; set; } [SchemaMethod] public void PlaceOrder() { // Perform some business logic to place the order // ... } }