mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
refactor(dir): ♻ simplify query mapping profiles
This commit is contained in:
parent
aa377e9956
commit
6d26e60a9f
8 changed files with 30 additions and 39 deletions
|
|
@ -38,11 +38,9 @@ internal class LanguageVmProfile : Profile
|
|||
{
|
||||
public LanguageVmProfile()
|
||||
{
|
||||
CreateMap<Language, LanguageVm>()
|
||||
.ForMember(l => l.FilterListIds,
|
||||
o => o.MapFrom(l =>
|
||||
l.FilterListLanguages.Select(fll => fll.FilterListId).OrderBy(flid => flid)
|
||||
.AsEnumerable()));
|
||||
CreateMap<Language, LanguageVm>().ForMember(l => l.FilterListIds,
|
||||
o => o.MapFrom(l =>
|
||||
l.FilterListLanguages.OrderBy(fll => fll.FilterListId).Select(fll => fll.FilterListId)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,10 +37,8 @@ internal class LicenseVmProfile : Profile
|
|||
{
|
||||
public LicenseVmProfile()
|
||||
{
|
||||
CreateMap<License, LicenseVm>()
|
||||
.ForMember(l => l.FilterListIds,
|
||||
o => o.MapFrom(l =>
|
||||
l.FilterLists.Select(fl => fl.Id).OrderBy(flid => flid).AsEnumerable()));
|
||||
CreateMap<License, LicenseVm>().ForMember(l => l.FilterListIds,
|
||||
o => o.MapFrom(l => l.FilterLists.OrderBy(fl => fl.Id).Select(fl => fl.Id)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,44 +50,42 @@ public ListDetailsVmProfile()
|
|||
CreateMap<FilterList, ListDetailsVm>()
|
||||
.ForMember(fl => fl.SyntaxIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.FilterListSyntaxes.Select(fls => fls.SyntaxId).OrderBy(sid => sid).AsEnumerable()))
|
||||
fl.FilterListSyntaxes.OrderBy(fls => fls.SyntaxId).Select(fls => fls.SyntaxId)))
|
||||
.ForMember(fl => fl.Iso6391s,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.FilterListLanguages.Select(fls => fls.Iso6391).OrderBy(i => i).AsEnumerable()))
|
||||
fl.FilterListLanguages.OrderBy(fll => fll.Iso6391).Select(fll => fll.Iso6391)))
|
||||
.ForMember(fl => fl.TagIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.FilterListTags.Select(flt => flt.TagId).OrderBy(tid => tid).AsEnumerable()))
|
||||
fl.FilterListTags.OrderBy(flt => flt.TagId).Select(flt => flt.TagId)))
|
||||
.ForMember(fl => fl.ViewUrls,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.ViewUrls.OrderBy(u => u.SegmentNumber).ThenBy(u => u.Primariness).AsEnumerable()))
|
||||
fl.ViewUrls.OrderBy(u => u.SegmentNumber).ThenBy(u => u.Primariness)))
|
||||
.ForMember(fl => fl.MaintainerIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.FilterListMaintainers.Select(flm => flm.MaintainerId).OrderBy(mid => mid)
|
||||
.AsEnumerable()))
|
||||
fl.FilterListMaintainers.OrderBy(flm => flm.MaintainerId).Select(flm => flm.MaintainerId)))
|
||||
.ForMember(fl => fl.UpstreamFilterListIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.UpstreamFilterLists.Select(ufl => ufl.UpstreamFilterListId).OrderBy(flid => flid)
|
||||
.AsEnumerable()))
|
||||
fl.UpstreamFilterLists.OrderBy(f => f.UpstreamFilterListId)
|
||||
.Select(f => f.UpstreamFilterListId)))
|
||||
.ForMember(fl => fl.ForkFilterListIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.ForkFilterLists.Select(ffl => ffl.ForkFilterListId).OrderBy(flid => flid)
|
||||
.AsEnumerable()))
|
||||
fl.ForkFilterLists.OrderBy(f => f.ForkFilterListId).Select(f => f.ForkFilterListId)))
|
||||
.ForMember(fl => fl.IncludedInFilterListIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.IncludedInFilterLists.Select(iifl => iifl.IncludedInFilterListId).OrderBy(flid => flid)
|
||||
.AsEnumerable()))
|
||||
fl.IncludedInFilterLists.OrderBy(m => m.IncludedInFilterListId)
|
||||
.Select(m => m.IncludedInFilterListId)))
|
||||
.ForMember(fl => fl.IncludesFilterListIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.IncludesFilterLists.Select(ifl => ifl.IncludesFilterListId).OrderBy(flid => flid)
|
||||
.AsEnumerable()))
|
||||
fl.IncludesFilterLists.OrderBy(m => m.IncludesFilterListId)
|
||||
.Select(m => m.IncludesFilterListId)))
|
||||
.ForMember(fl => fl.DependencyFilterListIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.DependencyFilterLists.Select(dfl => dfl.DependencyFilterListId).OrderBy(flid => flid)
|
||||
.AsEnumerable()))
|
||||
fl.DependencyFilterLists.OrderBy(d => d.DependencyFilterListId)
|
||||
.Select(d => d.DependencyFilterListId)))
|
||||
.ForMember(fl => fl.DependentFilterListIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.DependentFilterLists.Select(dfl => dfl.DependentFilterListId).OrderBy(flid => flid)
|
||||
.AsEnumerable()));
|
||||
fl.DependentFilterLists.OrderBy(d => d.DependentFilterListId)
|
||||
.Select(d => d.DependentFilterListId)));
|
||||
|
||||
CreateMap<FilterListViewUrl, ListDetailsVm.ViewUrlVm>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,21 +41,20 @@ public ListVmProfile()
|
|||
CreateMap<FilterList, ListVm>()
|
||||
.ForMember(fl => fl.SyntaxIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.FilterListSyntaxes.Select(fls => fls.SyntaxId).OrderBy(sid => sid).AsEnumerable()))
|
||||
fl.FilterListSyntaxes.OrderBy(fls => fls.SyntaxId).Select(fls => fls.SyntaxId)))
|
||||
.ForMember(fl => fl.Iso6391s,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.FilterListLanguages.Select(fls => fls.Iso6391).OrderBy(i => i).AsEnumerable()))
|
||||
fl.FilterListLanguages.OrderBy(fll => fll.Iso6391).Select(fll => fll.Iso6391)))
|
||||
.ForMember(fl => fl.TagIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.FilterListTags.Select(flt => flt.TagId).OrderBy(tid => tid).AsEnumerable()))
|
||||
fl.FilterListTags.OrderBy(flt => flt.TagId).Select(flt => flt.TagId)))
|
||||
.ForMember(fl => fl.PrimaryViewUrl,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.ViewUrls.OrderBy(u => u.SegmentNumber).ThenBy(u => u.Primariness).Select(u => u.Url)
|
||||
.FirstOrDefault()))
|
||||
.ForMember(fl => fl.MaintainerIds,
|
||||
o => o.MapFrom(fl =>
|
||||
fl.FilterListMaintainers.Select(flm => flm.MaintainerId).OrderBy(mid => mid)
|
||||
.AsEnumerable()));
|
||||
fl.FilterListMaintainers.OrderBy(flm => flm.MaintainerId).Select(flm => flm.MaintainerId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ public MaintainerVmProfile()
|
|||
CreateMap<Maintainer, MaintainerVm>()
|
||||
.ForMember(m => m.FilterListIds,
|
||||
o => o.MapFrom(m =>
|
||||
m.FilterListMaintainers.Select(flm => flm.FilterListId).OrderBy(flid => flid)
|
||||
.AsEnumerable()));
|
||||
m.FilterListMaintainers.OrderBy(flm => flm.FilterListId).Select(flm => flm.FilterListId)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ public SoftwareVmProfile()
|
|||
{
|
||||
CreateMap<Software, SoftwareVm>()
|
||||
.ForMember(s => s.SyntaxIds,
|
||||
o => o.MapFrom(s =>
|
||||
s.SoftwareSyntaxes.Select(ss => ss.SyntaxId).OrderBy(sid => sid).AsEnumerable()));
|
||||
o => o.MapFrom(s => s.SoftwareSyntaxes.OrderBy(ss => ss.SyntaxId).Select(ss => ss.SyntaxId)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@ public SyntaxVmProfile()
|
|||
CreateMap<Syntax, SyntaxVm>()
|
||||
.ForMember(s => s.FilterListIds,
|
||||
o => o.MapFrom(s =>
|
||||
s.FilterListSyntaxes.Select(sls => sls.FilterListId).OrderBy(flid => flid).AsEnumerable()))
|
||||
s.FilterListSyntaxes.OrderBy(fls => fls.FilterListId).Select(sls => sls.FilterListId)))
|
||||
.ForMember(s => s.SoftwareIds,
|
||||
o => o.MapFrom(s =>
|
||||
s.SoftwareSyntaxes.Select(ss => ss.SoftwareId).OrderBy(sid => sid).AsEnumerable()));
|
||||
s.SoftwareSyntaxes.OrderBy(ss => ss.SoftwareId).Select(ss => ss.SoftwareId)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public TagVmProfile()
|
|||
CreateMap<Tag, TagVm>()
|
||||
.ForMember(t => t.FilterListIds,
|
||||
o => o.MapFrom(t =>
|
||||
t.FilterListTags.Select(flt => flt.FilterListId).OrderBy(flid => flid).AsEnumerable()));
|
||||
t.FilterListTags.OrderBy(flt => flt.FilterListId).Select(flt => flt.FilterListId)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue