Skip to content

Instantly share code, notes, and snippets.

@PascalSenn
Created February 9, 2022 20:46
Show Gist options
  • Save PascalSenn/0f9d6c6824975575495877bdf266d586 to your computer and use it in GitHub Desktop.
Save PascalSenn/0f9d6c6824975575495877bdf266d586 to your computer and use it in GitHub Desktop.
Data Next
public class Person
{
public string FirstName { get; }
public string LastName { get; }
}
[ExtendObjectType(typeof(Person))]
public class PersonExtension
{
public Expression DisplayName = (Person p ) => $"{p.FirstName} {p.LastName}";
public string DisplayName(
[Field("firstName")]string firstName,
[Field("lastName")]string lastName])
=> $"{p.FirstName} {p.LastName}";
public string DisplayName(
[Member(nameof(Person.FirstName))]string firstName,
[Member(nameof(Person.LastName))]string lastName])
=> $"{p.FirstName} {p.LastName}";
}
public interface IFilterinContext{}
// customer land 🪄
public static class FooBarDatabaseMapper
{
public static FooBarQuery Map(this IFilteringContext context) { /* */}
}
/*
.Select(x => new Person { FirstName = x.FirstName, LastName = x.LastName, Displ})
1. Map the output type to filtering
2. FilteringContext , ProjectionContext et al
3. lift expression from output type to filtering projection and sorting
3.1 Projection Engine
.Select(x => new object[] { x.FirstName, x.LastName, $"{x.FirstName} {x.LastName}"})
firstName x => x.GetParent<object[]>()[0];
lastName x => x.GetParent<object[]>()[1];
displayName x => x.GetParent<object[]>()[1];
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment