Created
January 24, 2020 20:09
-
-
Save cezarypiatek/f8bcc6c090ec1b12ec3c8936facae2f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace ConsoleApp9 | |
{ | |
public class Tenant | |
{ | |
public string Key { get; set; } | |
public string Description { get; set; } | |
} | |
public class User | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public IList<UserRequest> Requests { get; } = new List<UserRequest>(); | |
public string Tenant { get; set; } | |
} | |
public class Request | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public DateTime TimeStamp { get; set; } | |
public string Category { get; set; } | |
public IList<UserRequest> Users { get; } = new List<UserRequest>(); | |
} | |
public class UserRequest | |
{ | |
public User User { get; set; } | |
public int UserId { get; set; } | |
public Request Request { get; set; } | |
public int RequestId { get; set; } | |
} | |
public class UserView | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public int LastRequestId { get; set; } | |
public string LastRequestName { get; set; } | |
public DateTime LastRequestTimeStamp { get; set; } | |
} | |
public class TenantView | |
{ | |
public string Key { get; set; } | |
public string Description { get; set; } | |
public int UserId { get; set; } | |
public string UserName { get; set; } | |
} | |
public class RequestsView | |
{ | |
public int UserId { get; set; } | |
public string UserName { get; set; } | |
public int Year { get; set; } | |
public int Month { get; set; } | |
public int Count { get; set; } | |
} | |
public class RequestView | |
{ | |
public int UserId { get; set; } | |
public string UserName { get; set; } | |
public int RequestId { get; set; } | |
public string RequestName { get; set; } | |
} | |
public static class Examples | |
{ | |
public static IEnumerable<UserView> LetStatement(IEnumerable<User> users) | |
{ | |
return from u in users | |
let ur = u.Requests.OrderBy(r => r.Request.TimeStamp).Last() | |
let r = ur.Request | |
select new UserView | |
{ | |
[||] | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment