Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Left Outer Join and SoftDelete #3899


User avatar
0
mamak created

In my left outer join; when I update all of right table's(Ihtiyac_Muayene_Iliski) IsDeleted = True, no Result returns. But I have a record in my left table(Muayene), so it must return my left table's rows...

My query:

var query = from HstTkp_Hasta in _hastaRepository.GetAll() join HstTkp_Muayene in _muayeneRepository.GetAll() on new { Id = HstTkp_Hasta.Id } equals new { Id = HstTkp_Muayene.HastaId } join HstTkp_Yapilan_Islem_Hasta in _yapilanIslemHastaRepository.GetAll() on new { Id = HstTkp_Muayene.Id } equals new { Id = HstTkp_Yapilan_Islem_Hasta.MuayeneId } join HstTkp_Yapilan_Islem_Iliski in _yapilanIslemIliskiRepository.GetAll() on new { Id = HstTkp_Yapilan_Islem_Hasta.Id } equals new { Id = HstTkp_Yapilan_Islem_Iliski.Yapilan_Islem_Hasta_Id } into HstTkp_Yapilan_Islem_Iliski_join from HstTkp_Yapilan_Islem_Iliski in HstTkp_Yapilan_Islem_Iliski_join.DefaultIfEmpty() join HstTkp_Yapilan_Islem_Parametre in _yapilanIslemParametreRepository.GetAll() on new { Id = HstTkp_Yapilan_Islem_Iliski.Yapilan_Islem_Parametre_Id } equals new { Id = HstTkp_Yapilan_Islem_Parametre.Id } join HstTkp_Ihtiyac_Muayene_Iliski in _ihtiyacMuayeneIliskiRepository.GetAll() on new { Id = HstTkp_Muayene.Id } equals new { Id = HstTkp_Ihtiyac_Muayene_Iliski.Muayene_Id } into HstTkp_Ihtiyac_Muayene_Iliski_join from HstTkp_Ihtiyac_Muayene_Iliski in HstTkp_Ihtiyac_Muayene_Iliski_join.DefaultIfEmpty() join HstTkp_Ihtiyac in _ihtiyacRepository.GetAll() on new { Id = HstTkp_Ihtiyac_Muayene_Iliski.Ihtiyac_Id } equals new { Id = HstTkp_Ihtiyac.Id }

                    select new MuayeneDetayliListDto
                    {
                        HastaId = HstTkp_Hasta.Id,
                        TcKimlikNo = HstTkp_Hasta.TcKimlikNo,
                        Adi = HstTkp_Hasta.Adi,
                        Soyadi = HstTkp_Hasta.Soyadi,
                        DogumTarihi = HstTkp_Hasta.DogumTarihi,
                        EvTel = HstTkp_Hasta.EvTel,
                        CepTel = HstTkp_Hasta.CepTel,
                        MuayeneId = HstTkp_Muayene.Id,
                        Muayene_Tarihi = HstTkp_Muayene.Muayene_Tarihi,
                        Sikayet = HstTkp_Muayene.Sikayet,
                        Deri = HstTkp_Muayene.Deri,
                        Bas_Boyun = HstTkp_Muayene.Bas_Boyun,
                        Solunum_Sistemi = HstTkp_Muayene.Solunum_Sistemi,
                        Sindirim_Sistemi = HstTkp_Muayene.Sindirim_Sistemi,
                        Kardiyovaskuler_Sistem = HstTkp_Muayene.Kardiyovaskuler_Sistem,
                        Norolojik_Muayene = HstTkp_Muayene.Norolojik_Muayene,
                        Kas_Eklem_Sistemi = HstTkp_Muayene.Kas_Eklem_Sistemi,
                        Genel = HstTkp_Muayene.Genel,
                        Hasta_Durumu = HstTkp_Muayene.Hasta_Durumu,
                        Tani = HstTkp_Muayene.Tani,
                        Buyuk_Tansiyon = HstTkp_Yapilan_Islem_Hasta.Buyuk_Tansiyon,
                        Kucuk_Tansiyon = HstTkp_Yapilan_Islem_Hasta.Kucuk_Tansiyon,
                        Nabiz = HstTkp_Yapilan_Islem_Hasta.Nabiz,
                        Solunum_Sayisi  = HstTkp_Yapilan_Islem_Hasta.Solunum_Sayisi,
                        Kan_Sekeri = HstTkp_Yapilan_Islem_Hasta.Kan_Sekeri,
                        Sonuc = HstTkp_Yapilan_Islem_Hasta.Sonuc,
                        Karar = HstTkp_Yapilan_Islem_Hasta.Karar,
                        Yapilan_Islem_Adi = HstTkp_Yapilan_Islem_Parametre.Parametre_Adi,
                        Ihtiyac_Adi = HstTkp_Ihtiyac.Ihtiyac_Adi
                    };

        query = query
            .WhereIf(input.HastaId.HasValue, item => item.HastaId.Equals(input.HastaId))
            .AsQueryable();

        var results = query.ToList();

3 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    hi

    this is out of scope of Asp.Net Zero framework. maybe you can get help from stackoverflow.

  • User Avatar
    0
    mamak created

    You say that this is out of scope of Asp.Net Zero framework but my linq query is converted to below sql sentence by Asp.Net Zero framework isn't?

    SELECT [Extent1].[Id] AS [Id], [Extent1].[TcKimlikNo] AS [TcKimlikNo], [Extent1].[Adi] AS [Adi], [Extent1].[Soyadi] AS [Soyadi], [Extent1].[DogumTarihi] AS [DogumTarihi], [Extent1].[EvTel] AS [EvTel], [Extent1].[CepTel] AS [CepTel], [Extent2].[Id] AS [Id1], [Extent2].[Muayene_Tarihi] AS [Muayene_Tarihi], [Extent2].[Sikayet] AS [Sikayet], [Extent2].[Deri] AS [Deri], [Extent2].[Bas_Boyun] AS [Bas_Boyun], [Extent2].[Solunum_Sistemi] AS [Solunum_Sistemi], [Extent2].[Sindirim_Sistemi] AS [Sindirim_Sistemi], [Extent2].[Kardiyovaskuler_Sistem] AS [Kardiyovaskuler_Sistem], [Extent2].[Norolojik_Muayene] AS [Norolojik_Muayene], [Extent2].[Kas_Eklem_Sistemi] AS [Kas_Eklem_Sistemi], [Extent2].[Genel] AS [Genel], [Extent2].[Hasta_Durumu] AS [Hasta_Durumu], [Extent2].[Tani] AS [Tani], [Extent3].[Buyuk_Tansiyon] AS [Buyuk_Tansiyon], [Extent3].[Kucuk_Tansiyon] AS [Kucuk_Tansiyon], [Extent3].[Nabiz] AS [Nabiz], [Extent3].[Solunum_Sayisi] AS [Solunum_Sayisi], [Extent3].[Kan_Sekeri] AS [Kan_Sekeri], [Extent3].[Sonuc] AS [Sonuc], [Extent3].[Karar] AS [Karar], [Extent5].[Parametre_Adi] AS [Parametre_Adi], [Extent7].[Ihtiyac_Adi] AS [Ihtiyac_Adi] FROM [dbo].[HstTkp_Hasta] AS [Extent1] INNER JOIN [dbo].[HstTkp_Muayene] AS [Extent2] ON [Extent1].[Id] = [Extent2].[HastaId] INNER JOIN [dbo].[HstTkp_Yapilan_Islem_Hasta] AS [Extent3] ON [Extent2].[Id] = [Extent3].[MuayeneId] LEFT OUTER JOIN [dbo].[HstTkp_Yapilan_Islem_Iliski] AS [Extent4] ON (([Extent4].[IsDeleted] = @DynamicFilterParam_000001) OR (@DynamicFilterParam_000002 IS NOT NULL)) AND ([Extent3].[Id] = [Extent4].[Yapilan_Islem_Hasta_Id]) INNER JOIN [dbo].[HstTkp_Yapilan_Islem_Parametre] AS [Extent5] ON [Extent4].[Yapilan_Islem_Parametre_Id] = [Extent5].[Id] LEFT OUTER JOIN [dbo].[HstTkp_Ihtiyac_Muayene_Iliski] AS [Extent6] ON (([Extent6].[IsDeleted] = @DynamicFilterParam_000001) OR (@DynamicFilterParam_000002 IS NOT NULL)) AND ([Extent2].[Id] = [Extent6].[Muayene_Id]) INNER JOIN [dbo].[HstTkp_Ihtiyac] AS [Extent7] ON [Extent6].[Ihtiyac_Id] = [Extent7].[Id]

    WHERE (([Extent1].[IsDeleted] = @DynamicFilterParam_000001) OR (@DynamicFilterParam_000002 IS NOT NULL)) AND (([Extent2].[IsDeleted] = @DynamicFilterParam_000001) OR (@DynamicFilterParam_000002 IS NOT NULL)) AND (([Extent3].[IsDeleted] = @DynamicFilterParam_000001) OR (@DynamicFilterParam_000002 IS NOT NULL)) AND (([Extent5].[IsDeleted] = @DynamicFilterParam_000001) OR (@DynamicFilterParam_000002 IS NOT NULL)) AND (([Extent7].[IsDeleted] = @DynamicFilterParam_000001) OR (@DynamicFilterParam_000002 IS NOT NULL))
    
  • User Avatar
    0
    alper created
    Support Team

    no, it's done by entity framework.