How can I test TryPush with settings? - tdd

I'm going to test next controller:
public ActionResult Approve(UpdateBalanceCommand input)
{
return TryPush(input, setting => setting.SuccessResult = () => Redirect(Url.Action("Index", "Home").SetHash(Url.Action("Index", "Payment"))));
}
How can I test the fact that the command had been executed with necessary settings?
Sincerelly,
Anton.

Please use like this
Establish establish = () =>
{
command = Pleasure.Generator.Invent<UpdateBalanceCommand >();
mockController = MockController<SomeController>
.When();
};
Because of = () => { result = mockController.Original.Approve(command); };
It should_be_push = () => mockController.ShouldBePush(command);
It should_be_result = () => result.ShouldBeRedirect("your url");

See working solution below
Establish establish = () =>
{
_command = Pleasure.Generator.Invent<UpdateBalanceCommand>();
_paymentController = MockController<PaymentController>.When()
.StubUrlAction("/")
.StubUrlAction("/Payment");
};
Because of = () => _result = _paymentController.Original.Approve(_command);
It should_push_command = () => _paymentController.ShouldBePush(_command);
It should_be_redirect = () => _result.ShouldBeRedirect("/#!Payment?");

Related

laravel excel import update only if there is a change

i have laravel excel maatwebsite import update function, it works really well but i want to mark record that change by add "correction_flag" variable. the question is, how can i set this "correction_flag" when import.
this is my import function:
public function collection(Collection $rows)
{
foreach ($rows as $row)
{
$tgl_lahir_cell = $this->transformDate($row['tanggal_lahir']);
$tgl_awal_masa_kerja_cell = $this->transformDate($row['tanggal_awal_masa_kerja']);
$tgl_menjadi_permanen_cell = $this->transformDate($row['tanggal_menjadi_permanen']);
$tgl_keluar_cell = $this->transformDate($row['tanggal_keluar']);
if($tgl_lahir_cell == '1970-01-01') {
$formatedDate1 = NULL;
}else{
$formatedDate1 = $tgl_lahir_cell;
}
if($tgl_awal_masa_kerja_cell == '1970-01-01') {
$formatedDate2 = NULL;
}else{
$formatedDate2 = $tgl_awal_masa_kerja_cell;
}
if($tgl_menjadi_permanen_cell == '1970-01-01') {
$formatedDate3 = NULL;
}else{
$formatedDate3 = $tgl_menjadi_permanen_cell;
}
if($tgl_keluar_cell == '1970-01-01') {
$formatedDate4 = NULL;
}else{
$formatedDate4 = $tgl_keluar_cell;
}
Tempdat::where('cc', Auth::user()->ccode)
->where('id_tempdat', $row['id_tempdat'])
->update([
'golongan' => $row['golongan'],
'nama' => $row['nama'],
'jenis_kelamin' => $row['jenis_kelamin'],
'tgl_lahir' => $formatedDate1,
'tgl_awal_masa_kerja' => $formatedDate2,
'tgl_menjadi_permanen' => $formatedDate3,
'status_awal' => $row['status_di_awal_periode'],
'gaji_pokok_awal' => $row['gaji_pokok_di_awal_periode'],
'tunjangan_tetap_awal' => $row['tunjangan_tetap_di_awal_periode'],
'total_upah_awal' => $row['total_upah_di_awal_periode'],
'status_akhir' => $row['status_di_akhir_periode'],
'tgl_keluar' => $formatedDate4,
'status2_akhir' => $row['keterangan_keluar'],
'gaji_pokok_akhir' => $row['gaji_pokok_di_akhir_periode'],
'tunjangan_tetap_akhir' => $row['tunjangan_tetap_di_akhir_periode'],
'total_upah_akhir' => $row['total_upah_di_akhir_periode'],
'jumlah_pesangon_paid_awal' => $row['pesangon_dibayarkan_pada_periode'],
'correction_flag' => 'CORRECTED'
]);
}
}
public function headingRow(): int
{
return 4;
}
public function startRow(): int
{
return 5;
}
i already tried to put correction_flag like the example above but its just make all record uploaded marked CORRECTED eventhou there is no changes happend.
You need to first() the query, because laravel model event listeners won't work if there's mass update/create. So what you need to do is:
$tempdat = Tempdat::where('cc', Auth::user()->ccode)->where('id_tempdat', $row['id_tempdat'])->first();
if($tempdat){
$tempdat->update([
...
]);
}
And add this function to your Temptdat model:
protected static function booted()
{
parent::boot();
self::saving(function ($model) {
if ($model->isDirty()) {
$model->correction_flag = 'CORRECTED';
}
});
}

Cannot compose correct Linq query for a class having collection properties - getting EfCore5 translation errors

I have flat collection of the following data (IQueryable<Article>) which was obtained by querying DB:
ArticleId
LanguageName
ArticleText
ExtraData1
ExtraData2
1
English
EngText1
Something1
Something2
1
English
EngText2
Another1
Another2
1
French
FraText1
Blabla1
2
English
EngText2
Ololo1
Blabla2
2
German
GerText1
Naturlisch2
Now I need to fill the IQueryable<AgregatedArticle>: the idea is grouping by ArticleId and putting repeating data into nested list:
public class AgregatedArticle {
public int ArticleId { get; set; }
public List<Data> ArticleTexts { get; set; }
public class Data {
public string LanguageName { get; set; }
public string ArticleText { get; set; }
}
}
Unfortunately, I cannot make it: I am getting various EfCore5 translation errors and don't know: if it's me or EfCore5 bugs or limitations. I wasted 3 days trying different approaches. Please help - I was unable to find suitable examples in Internet. The problem comes up when I try to fill ArticleTexts property.
Here is the simplified example:
private async Task<IQueryable<LawArticleAggregated>> GetLawArticlesGroupedById(DbSet<LawArticleDetail> dbSet, string userContentLangRestriction = null)
{
var dbContext = await GetDbContextAsync();
var articlesQuery =
(from articleIds in dbSet.Select(x => x.ArticleId).Distinct()
from articlesPerId in dbSet
.Where(x => x.ArticleId == articleIds.ArticleId)
join askedL in dbContext.Langs
.Where(l => l.LanguageCode == userContentLangRestriction)
on
articlesPerId.LanguageCode
equals
askedL.StringValue
into askedLanguages
from askedLawLanguage in askedLanguages.DefaultIfEmpty()
join fallbackL in dbContext.Langs
.Where(l => l.LanguageCode == CoreConstants.LanguageCodes.English)
on
articlesPerId.LanguageCode
equals
fallbackL.StringValue
into fallbackLanguages
from fallbackLanguage in fallbackLanguages.DefaultIfEmpty()
select new
{
ArticleId = articleIds.ArticleId,
ArticleText = articlesPerId.ArticleText,
LanguageName = askedLawLanguage.ShortName ?? fallbackLanguage.ShortName
})
.OrderBy(x => x.ArticleId).ThenBy(x => x.LanguageName).ThenBy(x => x.ArticleText);
await articlesQuery.LoadAsync();
var aggregatedArticleData = articlesQuery.Select(x => new
{
ArticleId = x.ArticleId,
ArticleText = x.ArticleText,
LanguageName = x.LanguageName
});
var aggregatedArticles = articlesQuery.Select(x => x.ArticleId).Distinct().Select(x => new ArticleAggregated
{
ArticleId = x.ArticleId,
ArticleTexts = aggregatedArticleData.Where(a => a.ArticleId == x.ArticleId)
.Select(x => new LawArticleAggregated.Data
{
ArticleText = x.ArticleText,
LanguageName = x.LanguageName
}).ToList()
});
return aggregatedArticles;
}
For this specific code the exception is as follows:
Unable to translate collection subquery in projection since the parent
query doesn't project key columns of all of it's tables which are
required to generate results on client side. This can happen when
trying to correlate on keyless entity or when using 'Distinct' or
'GroupBy' operations without projecting all of the key columns.
I think I have reverse engineered your query. Big difference that we cannot return IQueryable from this funcrtio, but prepared IEnumerable. So if you have pagination later, better to pass page info into function parameters.
private async Task<IEnumerable<LawArticleAggregated>> GetLawArticlesGroupedById(DbSet<LawArticleDetail> dbSet, string userContentLangRestriction = null)
{
var dbContext = await GetDbContextAsync();
var articlesQuery =
from article in dbSet
from askedLawLanguage in dbContext.Langs
.Where(askedLawLanguage => askedLawLanguage.LanguageCode == userContentLangRestriction && article.LanguageCode == askedLawLanguage.StringValue)
.DefaultIfEmpty()
from fallbackLanguage in dbContext.Langs
.Where(fallbackLanguage => fallbackLanguage.LanguageCode == CoreConstants.LanguageCodes.English && article.LanguageCode == fallbackLanguage.StringValue)
.DefaultIfEmpty()
select new
{
ArticleId = article.ArticleId,
ArticleText = article.ArticleText,
LanguageName = askedLawLanguage.ShortName ?? fallbackLanguage.ShortName
};
articlesQuery = articlesQuery
.OrderBy(x => x.ArticleId)
.ThenBy(x => x.LanguageName)
.ThenBy(x => x.ArticleText);
var loaded = await articlesQuery.ToListAsync();
// group on the client side
var aggregatedArticles = loaded.GroupBy(x => x.ArticleId)
.Select(g => new ArticleAggregated
{
ArticleId = g.Key,
ArticleTexts = g.Select(x => new LawArticleAggregated.Data
{
ArticleText = x.ArticleText,
LanguageName = x.LanguageName
}).ToList()
});
return aggregatedArticles;
}
I ended up with the following implementation (I show it "as is", without simplification from the first message to demonstrate the approach, slightly modified from the initial variant to use proper paging):
private async Task<IEnumerable<LawArticleAggregated>> GetLawArticlesGroupedByIdListAsync(
DbSet<LawArticleDetail> dbSet,
Expression<Func<IQueryable<LawArticleDetail>, IQueryable<LawArticleDetail>>> filterFunc,
int skipCount,
int maxResultCount,
string userContentLangRestriction = null,
CancellationToken cancellationToken = default
)
{
var dbContext = await GetDbContextAsync();
var articlesQuery =
(from articleIds in filterFunc.Compile().Invoke(dbSet).Select(x => new { x.TenantId, x.LawArticleId })
.Distinct().OrderBy(x => x.TenantId).OrderByDescending(x => x.LawArticleId).Skip(skipCount).Take(maxResultCount)
from articlesPerId in dbSet
.Where(x => x.TenantId == articleIds.TenantId && x.LawArticleId == articleIds.LawArticleId)
join askedL in dbContext.FixCodeValues
.Where(l =>
l.DomainId == CoreConstants.Domains.CENTRAL_TOOLS
&& l.CodeName == CoreConstants.FieldTypes.LANGUAGE
&& l.LanguageCode == userContentLangRestriction)
on
articlesPerId.LanguageCode
equals
askedL.StringValue
into askedLanguages
from askedLawLanguage in askedLanguages.DefaultIfEmpty()
join fallbackL in dbContext.FixCodeValues
.Where(l =>
l.DomainId == CoreConstants.Domains.CENTRAL_TOOLS
&& l.CodeName == CoreConstants.FieldTypes.LANGUAGE
&& l.LanguageCode == CoreConstants.LanguageCodes.English)
on
articlesPerId.LanguageCode
equals
fallbackL.StringValue
into fallbackLanguages
from fallbackLanguage in fallbackLanguages.DefaultIfEmpty()
select new
{
TenantId = articleIds.TenantId,
LawArticleId = articleIds.LawArticleId,
Shortcut = articlesPerId.Shortcut,
ArticleText = articlesPerId.ArticleText,
LanguageName = askedLawLanguage.ShortName ?? fallbackLanguage.ShortName
})
.OrderBy(x => x.TenantId).ThenByDescending(x => x.LawArticleId).ThenBy(x => x.Shortcut).ThenBy(x => x.LanguageName).ThenBy(x => x.ArticleText);
var articleList = await articlesQuery.ToListAsync(cancellationToken);
var aggregatedArticles = articleList.GroupBy(x => new { x.TenantId, x.LawArticleId })
.Select(g => new LawArticleAggregated
{
TenantId = g.Key.TenantId,
LawArticleId = g.Key.LawArticleId,
ArticleTexts = g.Select(x => new LawArticleAggregated.Data
{
Shortcut = x.Shortcut,
ArticleText = x.ArticleText,
LanguageName = x.LanguageName
}).ToList()
});
return aggregatedArticles;
}
private async Task<long> GetLawArticlesGroupedByIdCountAsync(
DbSet<LawArticleDetail> dbSet,
Expression<Func<IQueryable<LawArticleDetail>, IQueryable<LawArticleDetail>>> filterFunc,
CancellationToken cancellationToken = default
)
{
return await filterFunc.Compile().Invoke(dbSet).GroupBy(x => new { x.TenantId, x.LawArticleId }).LongCountAsync(cancellationToken);
}

RXJS Emit true during one second, then false

Is there any way to do basically this:
this.success = true;
setTimeout(() => {
this.success = false;
}, 1000);
Using RXJS?
const success$ = timer(1000).pipe(map(_ => false), startWith(true));
success$.subscribe(x => console.log(x));
https://stackblitz.com/edit/rxjs-tpeyqk
Sure. use the timer() function:
this.success = true;
timer(1000).subscribe(() => this.success = false);

Yii2: How to validate relation?

I have a model with the relation called "reviews":
class ReportStructure extends \yii\db\ActiveRecord
{
const REVIEW_LIST_NAME = 'reviews';
public function getReviewList()
{
return $this->hasOne(FileIndexList::className(), ['id_owner' => 'id_report'])
->where('list_name = :list_name', [':list_name' => self::REVIEW_LIST_NAME]);
}
public function getReviews()
{
return $this->hasMany(FileIndex::className(), ['id_file_index' => 'id_file_index'])->via('reviewList');
}
}
In View, the reviews are displayed by GridView widget. The user can add or delete reviews by the other View. The user should specify at least one review. I added the validation rule to the model:
public function rules()
{
return [
['reviews', 'checkReviews'],
];
}
public function checkReviews($attribute)
{
if (count($this->reviews) === 0) {
$this->addError($attribute, 'You should add at least one review');
}
}
But it seems that rule even not fired.
public function actionIndex($idSupply, $restoreTab = false) {
$this->initData($idSupply, $report, $reestrData, $structure, $elements);
$ok = $report->load(Yii::$app->request->post()) &&
$reestrData->load(Yii::$app->request->post()) &&
Model::loadMultiple($elements, Yii::$app->request->post());
if($ok) {
$ok = $report->validate() &&
$reestrData->validate() &&
Model::validateMultiple($elements) &&
$structure->validate();
if($ok) {
$report->id_status = Status::STATUS_VERIFIED;
$this->saveData($report, $reestrData, $structure, $elements);
return $this->redirect(['supplies/update', 'id' => $idSupply]);
}
}
return $this->render('index', [
'structure' => $structure,
'report' => $report,
'reestrData' => $reestrData,
'elements' => $elements,
'restoreTab' => $restoreTab
]);
}
That's how the data is initialized. $elements are the objects of one class, I use tabular input for them.
private function initData($idSupply, &$report, &$reestrData, &$structure, &$elements) {
$report = \app\models\Reports::findOne($idSupply);
$reestrData = \app\models\ReestrData::findOne($report->id_reestr_data);
$structure = \app\models\report\ReportStructure::findOne($report->id_supply);
$elements = [
'titleIndex' => FileIndex::getInstance($structure->id_title_index, $structure->getAttributeLabel('id_title_index')),
'abstractIndex' => FileIndex::getInstance($structure->id_abstract_index, $structure->getAttributeLabel('id_abstract_index')),
'technicalSpecificationIndex' => FileIndex::getInstance($structure->id_technical_specification_index, $structure->getAttributeLabel('id_technical_specification_index')),
'contentsIndex' => FileIndex::getInstance($structure->id_contents_index, $structure->getAttributeLabel('id_contents_index')),
'imageListIndex' => FileIndex::getInstance($structure->id_image_list_index, $structure->getAttributeLabel('id_image_list_index'), false),
'tableListIndex' => FileIndex::getInstance($structure->id_table_list_index, $structure->getAttributeLabel('id_table_list_index'), false),
'textAnnexListIndex' => FileIndex::getInstance($structure->id_text_annex_list_index, $structure->getAttributeLabel('id_text_annex_list_index'), false),
'graphAnnexListIndex' => FileIndex::getInstance($structure->id_graph_annex_list_index, $structure->getAttributeLabel('id_graph_annex_list_index'), false),
'glossaryIndex' => FileIndex::getInstance($structure->id_glossary_index, $structure->getAttributeLabel('id_glossary_index'), false),
'reportIntroductionIndex' => FileIndex::getInstance($structure->id_report_introduction_index, $structure->getAttributeLabel('id_report_introduction_index')),
'reportMainPartIndex' => FileIndex::getInstance($structure->id_report_main_part_index, $structure->getAttributeLabel('id_report_main_part_index')),
'reportConclusionIndex' => FileIndex::getInstance($structure->id_report_conclusion_index, $structure->getAttributeLabel('id_report_conclusion_index')),
'bibliographyIndex' => FileIndex::getInstance($structure->id_bibliography_index, $structure->getAttributeLabel('id_bibliography_index')),
'metrologicalExpertiseIndex' => FileIndex::getInstance($structure->id_metrologicalexpertise_index, $structure->getAttributeLabel('id_metrologicalexpertise_index')),
'patentResearchIndex' => FileIndex::getInstance($structure->id_patent_research_index, $structure->getAttributeLabel('id_patent_research_index')),
'costStatementIndex' => FileIndex::getInstance($structure->id_cost_statement_index, $structure->getAttributeLabel('id_cost_statement_index')),
];
}
And tht's how the data is saved:
private function saveData($report, $reestrData, $structure, $elements) {
$reestrData->save(false);
$report->save(false);
foreach ($elements as $element) {
$element->save(false);
}
$structure->id_title_index = $elements['titleIndex']->id_file_index;
$structure->id_abstract_index = $elements['abstractIndex']->id_file_index;
$structure->id_technical_specification_index = $elements['technicalSpecificationIndex']->id_file_index;
$structure->id_contents_index = $elements['contentsIndex']->id_file_index;
$structure->id_image_list_index = $elements['imageListIndex']->id_file_index;
$structure->id_table_list_index = $elements['tableListIndex']->id_file_index;
$structure->id_text_annex_list_index = $elements['textAnnexListIndex']->id_file_index;
$structure->id_graph_annex_list_index = $elements['graphAnnexListIndex']->id_file_index;
$structure->id_glossary_index = $elements['glossaryIndex']->id_file_index;
$structure->id_report_introduction_index = $elements['reportIntroductionIndex']->id_file_index;
$structure->id_report_main_part_index = $elements['reportMainPartIndex']->id_file_index;
$structure->id_report_conclusion_index = $elements['reportConclusionIndex']->id_file_index;
$structure->id_bibliography_index = $elements['bibliographyIndex']->id_file_index;
$structure->id_metrologicalexpertise_index = $elements['metrologicalExpertiseIndex']->id_file_index;
$structure->id_patent_research_index = $elements['patentResearchIndex']->id_file_index;
$structure->id_cost_statement_index = $elements['costStatementIndex']->id_file_index;
$structure->save(false);
}
I eventually decided not to use validation for the relation at all and simply check reviews count in the controller:
if (count($structure->reviews) === 0) {
$ok = false;
Yii::$app->session->setFlash('danger', 'You should add at least one review!');
}
I think it's better to check it in beforeDelete method.
you can add this method to your model, and check, if it's the only review, then returns false.
public function beforeDelete()
{
if (!parent::beforeDelete()) {
return false;
}
if(self::find()->count() >1)
return true;
else
return false;
}

join 4 tables with linq

I'm trying to join 4 tables using linq.
This is my code,
var query = Context.AanvraagV.Join(Context.IdnPartijMVSet, aanvraag => aanvraag.AlvNummer, partijMv => partijMv.AlvNummer, (aanvraag, partijMv) => new { aanvraag, partijMv })
.Join(Context.DossierVaststellingSet, aanvraag => aanvraag.aanvraag.AanvraagId, dossierVaststelling => dossierVaststelling.DossierVersieId, (aanvraag, dossierVaststelling) => new { aanvraag, dossierVaststelling })
.Join(Context.IdnPartijVoorkeurContactMVSet, aanvraag => aanvraag.aanvraag.partijMv.AlvNummer, partijVoorkeur => partijVoorkeur.AlvNummer, (aanvraag, partijVoorkeur) => new { aanvraag, partijVoorkeur });
Then I return a query and this is what I get
return query.Select(x => new ZoekResultaatDto{
AanvraagNummer = x.aanvraag.aanvraag.aanvraag.DossierNummer,
Versie = x.aanvraag.aanvraag.aanvraag.AanvraagVersie,
StartjaarAanvraag = x.aanvraag.aanvraag.aanvraag.AanvraagStartCampagne,
EindjaarAanvraag = x.aanvraag.aanvraag.aanvraag.AanvraagEindCampagne,
Maatregel = x.aanvraag.aanvraag.aanvraag.Maatregel,
Pakket = x.aanvraag.aanvraag.aanvraag.MaatregelPakket,
AanvraagType = x.aanvraag.aanvraag.aanvraag.Aanvragtype,
Eenheid = x.aanvraag.aanvraag.aanvraag.VerbintenisWaardeEenheid,
VerbintenisOppervlakte = x.aanvraag.aanvraag.aanvraag.VerbintenisWaarde,
KeuzeBevestiging = x.aanvraag.aanvraag.aanvraag.KeuzeBevestiging,
IndieningsdatumAanvraag = x.aanvraag.aanvraag.aanvraag.AanvraagIndieningsDatum,
Status = x.aanvraag.aanvraag.aanvraag.AanvraagStatus,
LandbouwerNummer = x.aanvraag.aanvraag.aanvraag.AlvNummer,
Naam = x.aanvraag.aanvraag.partijMv.Naam,
Rechtsvorm = x.aanvraag.aanvraag.partijMv.Rechtsvorm ,
Adres = string.Format("{0} {1} {2}", x.aanvraag.aanvraag.partijMv.Straat, x.aanvraag.aanvraag.partijMv.Huisnummer, x.aanvraag.aanvraag.partijMv.Bus),
Postcode = x.aanvraag.aanvraag.partijMv.Postcode,
Gemeente = x.aanvraag.aanvraag.partijMv.Gemeente,
EmailaAdres = x.partijVoorkeur.Email,
OpmerkingCode = x.aanvraag.dossierVaststelling.VaststellingCode,
OpmerkingOmschrijving = RefVaststellingResources.OMSCHRIJVING(x.aanvraag.dossierVaststelling)
}).ToList();
But this is not what I want. What i want is this. How can I change the joins to get this instead?
return query.Select(x => new ZoekResultaatDto{
AanvraagNummer = x.aanvraag.DossierNummer,
Versie = x.aanvraag.AanvraagVersie,
StartjaarAanvraag = x.aanvraag.AanvraagStartCampagne,
EindjaarAanvraag = x.aanvraag.AanvraagEindCampagne,
Maatregel = x.aanvraag.Maatregel,
Pakket = x.aanvraag.MaatregelPakket,
AanvraagType = x.aanvraag.Aanvragtype,
Eenheid = x.aanvraag.VerbintenisWaardeEenheid,
VerbintenisOppervlakte = x.aanvraag.VerbintenisWaarde,
KeuzeBevestiging = x.aanvraag.KeuzeBevestiging,
IndieningsdatumAanvraag = x.aanvraag.AanvraagIndieningsDatum,
Status = x.aanvraag.AanvraagStatus,
LandbouwerNummer = x.aanvraag.AlvNummer,
Naam = x.partijMv.Naam,
Rechtsvorm = x.partijMv.Rechtsvorm ,
Adres = string.Format("{0} {1} {2}", x.partijMv.Straat, x.partijMv.Huisnummer, x.partijMv.Bus),
Postcode = x.partijMv.Postcode,
Gemeente = x.partijMv.Gemeente,
EmailaAdres = x.partijVoorkeur.Email,
OpmerkingCode = x.dossierVaststelling.VaststellingCode,
OpmerkingOmschrijving = RefVaststellingResources.OMSCHRIJVING(x.dossierVaststelling)
}).ToList();
I did it. And also solved the problem of returning a AnonymousType
public class ZoekResultaatLijstDto
{
public AanvraagV aanvraag { get; set; }
public IdnPartijMV idnPartijMv { get; set; }
public DossierVaststelling dossierVast { get; set; }
public IdnPartijVoorkeurContactMV idnPartijVoor { get; set; }
}
public List<ZoekResultaatLijstDto> GetItems(ZoekCriteriaDto zoekCriteria)
{
IQueryable<ZoekResultaatLijstDto> query = Context.AanvraagV.Join(Context.IdnPartijMVSet, aanvraag => aanvraag.AlvNummer, partijMv => partijMv.AlvNummer, (aanvraag, partijMv) => new { aanvraag, partijMv })
.Join(Context.DossierVaststellingSet, aanvraag => aanvraag.aanvraag.AanvraagId, dossierVaststelling => dossierVaststelling.DossierVersieId,
(aanvraag, dossierVaststelling) => new { aanvraag, dossierVaststelling }).Select( j => new {j.aanvraag, j.aanvraag.partijMv, j.dossierVaststelling})
.Join(Context.IdnPartijVoorkeurContactMVSet, aanvraag => aanvraag.aanvraag.partijMv.AlvNummer, partijVoorkeur => partijVoorkeur.AlvNummer, (aanvraag, partijVoorkeur) => new { aanvraag, partijVoorkeur })
.Select(m => new ZoekResultaatLijstDto() { aanvraag = m.aanvraag.aanvraag.aanvraag, dossierVast = m.aanvraag.dossierVaststelling, idnPartijMv = m.aanvraag.partijMv, idnPartijVoor = m.partijVoorkeur });
return query.Select(zoekResultaat => zoekResultaat).ToList();
}

Resources