mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2026-06-13 10:15:35 +00:00
Updated readme and added new sample project
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EntityFrameworkCore.Projections;
|
||||
|
||||
namespace ReadmeSample.Entities
|
||||
{
|
||||
public class Order
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public DateTime CreatedDate { get; set; }
|
||||
|
||||
public decimal TaxRate { get; set; }
|
||||
|
||||
public User User { get; set; }
|
||||
public ICollection<OrderItem> Items { get; set; }
|
||||
|
||||
[Projectable] public decimal Subtotal => Items.Sum(item => item.Product.ListPrice * item.Quantity);
|
||||
[Projectable] public decimal Tax => Subtotal * TaxRate;
|
||||
[Projectable] public decimal GrandTotal => Subtotal + Tax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace ReadmeSample.Entities
|
||||
{
|
||||
public class OrderItem
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
|
||||
public Order Order { get; set; }
|
||||
public Product Product { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace ReadmeSample.Entities
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public decimal ListPrice { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ReadmeSample.Entities
|
||||
{
|
||||
public class User
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
public string EmailAddress { get; set; }
|
||||
|
||||
public ICollection<Order> Orders { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user