caloggins
6/30/2016 - 8:59 PM

Wet/dry examples.

Wet/dry examples.

public class GetLittleErrorThingsByCategory : IQuery<IEnumerable<string>>
{
  public IEnumerable<LittleErrors> Errors { get; set; }
  public Guid Category { get; set; }
}

public class GetLittleErrorThingsByCategoryHandler : IQueryHandler<GetLittleErrorThingsByCategory, IEnumerable<Thing>>
{
    // omitted...
    public IEnumerable<Thing> Handle(GetLittleErrorThingsByCategory query)
    {
      var things =
        (from error in query.Errors
          from things in databaseContext.Set<Thing>()
          where things.Id == error.ThingId
                && things.Category == query.Category
          select things);
          
      return things;
    }
}

public class GetBigErrorThingsByCategory : IQuery<IEnumerable<string>>
{
  public IEnumerable<BigErrors> Errors { get; set; }
  public Guid Category { get; set; }
}

public class GetBigErrorThingsByCategoryHandler : IQueryHandler<GetBigErrorThingsByCategory, IEnumerable<Thing>>
{
    // omitted...
    public IEnumerable<Thing> Handle(GetBigErrorThingsByCategory query)
    {
      var things =
        (from error in query.Errors
          from things in databaseContext.Set<Thing>()
          where things.Id == error.ThingId
                && things.Category == query.Category
          select things);
          
      return things;
    }
}