Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local sequence cannot be used in LINQ to SQL implementations of query operators except the Contains operator

I am getting this error on a webpage, on a Microsoft Report Viewer component:

An error has occurred during report processing. Local sequence cannot be used in LINQ to SQL implementations of query operators except the Contains operator.

My code:

public static IEnumerable GetUrunMiktarliDetayli()
{
    Baglanti();
    List<StokEnvanteriSatiri> urunListesi = new List<StokEnvanteriSatiri>();
    urunListesi = GetUrunListesiDoldur();

    var urunStok = from urunS in urunListesi
                   select new
                   {
                       urunS.AcilisMiktari,
                       urunS.MevcutMiktar,
                       urunS.UrunNo
                   };

    var urunMD = from urun in db.TBLP1URUNs
                 join kategori in db.TBLP1URUNKATEGORIs
                               on urun.KATEGORIID equals kategori.ID
                 join a in urunStok
                        on urun.ID equals a.UrunNo
                 select new
                 {
                     DIGERGIRISLER = a.AcilisMiktari,
                     urun.URUNADI,
                     urun.URUNACIKLAMA,
                     kategori.TREENAME,                         
                     urun.STOKTURU,
                     urun.MARKA,
                     urun.MODEL,
                     urun.URUNTIPI,
                     urun.URUNDURUM,
                     urun.KRITIKSTOKMIKTARI,
                     urun.DEPOADI,
                     urun.YER,
                     urun.RAF,
                     urun.RAFOMRU,
                     KDVDAHILMI = urun.KDVDAHILMI==1 ? "EVET":"HAYIR",
                     urun.KDVORANI,
                     urun.SATFIYAT1,
                     urun.SATFIYAT1BIRIM,
                     urun.TEDFIYAT1,
                     urun.TEDFIYAT1BIRIM,
                     urun.HIZMETYENSURYIL,
                     urun.HIZMETYENSURAY,
                     urun.SATILANMIKTAR,
                     urun.IADEEDILENMIKTAR,
                     urun.KULLANILANMIKTAR,
                     urun.ZAYIMIKTAR,
                     urun.KONSINYECIKISMIKTAR,
                     urun.DIGERCIKISLAR,
                     urun.TEDARIKMIKTAR,
                     urun.IADEALINANMIKTAR,
                     urun.KONSINYEGIRISMIKTAR,                         
                     urun.EN,
                     urun.BOY,
                     urun.YUKSEKLIK,
                     urun.AGIRLIK,
                     urun.BOYUTAGIRLIGI,
                     urun.URUNKAYITTARIHI,
                     urun.GARANTISURESIBITIS,
                     urun.SONGUNCELLEMETARIHI,
                     urun.YENI,
                     urun.TESLIMATSURESI,
                     urun.TEDARIKCISTOKMIKTAR,
                 }
                 ;
    return urunMD;
}

public class StokEnvanteriSatiri 
        {
            private string urunNo;
            private string urunAdi;
            private int acilisMiktari;
            private int toplamTedarikMiktari;
            private int toplamSatisMiktari;
            private int mevcutMiktar;
            private decimal satisFiyati;
            private decimal toplamTutar;
            private string paraBirimi;

            public string UrunNo 
            {
                get { return urunNo; }
                set { urunNo = value; }
            }

            public string UrunAdi 
            {
                get { return urunAdi; }
                set { urunAdi = value; }
            }

            public int AcilisMiktari 
            {
                get { return acilisMiktari; }
                set { acilisMiktari = value;}
            }

            public int ToplamTedarikMiktari 
            {
                get { return toplamTedarikMiktari; }
                set { toplamTedarikMiktari = value; }
            }

            public int ToplamSatisMiktari
            {
                get { return toplamSatisMiktari; }
                set { toplamSatisMiktari = value; }
            }

            public int MevcutMiktar 
            {
                get { return mevcutMiktar; }
                set { mevcutMiktar = value; }
            }

            public decimal SatisFiyati
            {
                get { return satisFiyati; }
                set { satisFiyati = value; }

            }

            public decimal ToplamTutar 
            {
                get { return toplamTutar; }
                set { toplamTutar = value; }
            }

            public string ParaBirimi 
            {
                get { return paraBirimi; }
                set { paraBirimi = value; }
            }

        }

This method GetUrunListesiDoldur() basically returns a List<StokEnvanteriSatiri> list of StokEnvanterSatiri, I know the problem is that I am trying to join an in-memory list with an SQL table.

Is there any way to handle this?

like image 621
Bastardo Avatar asked May 09 '11 11:05

Bastardo


1 Answers

I basically reversed the join and it worked

var urunMD = from urunStokbilgileri in urunStok
             join urun in db.TBLP1URUNs
                       on urunStokbilgileri.UrunNo equals urun.ID
             join kategori in db.TBLP1URUNKATEGORIs
                       on urun.KATEGORIID equals kategori.ID
             ......
like image 162
Bastardo Avatar answered Oct 22 '22 22:10

Bastardo