The local sequence cannot be used in LINQ to SQL implementations of query statements other than the Contains statement

I get this error on the Microsoft Report Viewer component web page:

An error occurred while processing the report. The local sequence cannot be used in implementations of LINQ to SQL query operators, except for Contains Statement.

My code is:

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 GetUrunListesiDoldur() method basically returns a List<StokEnvanteriSatiri> list of StokEnvanterSatiri , I know that the problem is that I'm trying to join a list in memory with an SQL table.

Is there any way to handle this?

+8
list c # linq-to-sql
source share
3 answers

I mainly drew attention to 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 ...... 
+7
source share

You need to get LINQ to evaluate the second connection locally. You can do it:

 var urunMD = (from urun in db.TBLP1URUNs join kategori in db.TBLP1URUNKATEGORIs on urun.KATEGORIID equals kategori.ID).AsEnumerable() .Join( [...] ) 
+3
source share

Rewrite the urunMD request to run in two parts. Use the Contains statement to filter the source records in TBLP1URUNs and then return only database data. Then use a separate LINQ-to-Objects query to combine the database data from TBLP1URUNs with the in-memory data in urunStok .

+2
source share

All Articles