mirror of
https://github.com/zoriya/EntityFrameworkCore.Projectables.git
synced 2025-12-19 03:55:11 +00:00
18 lines
514 B
C#
18 lines
514 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using EntityFrameworkCore.Projections;
|
|
using ReadmeSample.Entities;
|
|
|
|
namespace ReadmeSample.Extensions
|
|
{
|
|
public static class UserExtensions
|
|
{
|
|
[Projectable]
|
|
public static Order GetMostRecentOrderForUser(this User user, DateTime? cutoffDate)
|
|
=> user.Orders.Where(x => x.CreatedDate >= cutoffDate).OrderByDescending(x => x.CreatedDate).FirstOrDefault();
|
|
}
|
|
}
|