Witam.

Tworząc aplikację natknąłem się na problem. Mam utworzony model danych a nich między innymi 2 klasy(jest więcej ale w przykładzie chodzi o te 2)

Pierwsza Klasa dotyczy DokumentówWZ


 public partial class WZ_DWS_SITO
    {
        public string WZ { get; set; }
        public string WZ_DATA { get; set; }
        public string WZ_CZAS { get; set; }
        public string WZ_POZYCJA { get; set; }
        public string MATERIAL { get; set; }
        public string PARTIA { get; set; }
        public string ZAKLAD { get; set; }
        public string SKLAD { get; set; }
        public decimal WZ_ILOSC { get; set; }
        public string ZLECENIE { get; set; }
        public string ZLECENIE_DATA_UTWORZENIA { get; set; }
        public string KUNNR { get; set; }
        public string ZLECENIE_POZYCJA { get; set; }
        public decimal ZLECENIE_CENA_NETTO { get; set; }
        public decimal ZLECENIE_ILOSC { get; set; }
        public decimal ZLECENIE_NETTO { get; set; }
        public decimal ZLECENIE_KOSZT { get; set; }
        public string WWW { get; set; }
        public Nullable<decimal> ZLECENIE_CENA_ZAKUPU { get; set; }
        public Nullable<decimal> ZLECENIE_ZYSK { get; set; }
        public Nullable<decimal> ZLECENIE_MARZA { get; set; }
        public string VE { get; set; }
        public Nullable<decimal> WZ_KOSZT { get; set; }
        public Nullable<decimal> WZ_NETTO { get; set; }
        public Nullable<decimal> WZ_ZYSK { get; set; }
        public Nullable<decimal> WZ_CALA_NETTO { get; set; }
        public Nullable<decimal> ATP_SKLAD { get; set; }
        public Nullable<decimal> ATP_ZAKLAD { get; set; }
        public string DATA_WYCENY { get; set; }
        public Nullable<decimal> CENA_MINIMALNA { get; set; }
        public Nullable<decimal> WZ_ILOSC_NA_WZ { get; set; }
        public Nullable<decimal> ILOSC_60DNI_ABC_5PROCENT { get; set; }
        public string PRZYCZYNA { get; set; }
        public string STATUS { get; set; }
        public string L0 { get; set; }
        public string L1 { get; set; }
        public string L2 { get; set; }
        public string NAZWA_KLIENTA { get; set; }
        public Nullable<int> INDEKS { get; set; }
        public string NAZWA_MATERIALU { get; set; }
        public string PH { get; set; }
        public Nullable<decimal> MARZA_ZLECENIE_ALL { get; set; }
    }

Druga zbiera historię zaakceptowanych dokumentów :


 public class HISTORYWZ
    {
        public string NrWZ { get; set; }
        public string ODBIORCA { get; set; }
        public string DATAWZ { get; set; }

        public int INDEKS { get; set; }
        public string MATERIAL { get; set; }
        public string PARTIA { get; set; }
        public decimal ILOSC { get; set; }
        public string NAZWA_MATERIALU { get; set; }
        public string PRZYCZYNA { get; set; }
        public decimal CENAMIN { get; set; }
        public decimal CENASPRZ { get; set; }
        public decimal VPRS { get; set; }
        public decimal MARZA { get; set; }

    }

Chciałbym wyciągając pojedyńczą WZ (która może mieć kilka pozycji) móc wrzucić ją do historii ale tylko elementy które są mi potrzebne.
Wyciągnąłem sobie elementy za pomocą LINQ :


 EntitiesSito ent = new EntitiesSito();
            dynamic wkaa = datagridview.SelectedItem;
            string actwuzetka = wkaa.WZ.ToString();

            var skad = (from d in ent.WZ_DWS_SITO
                        where d.WZ == actwuzetka
                        select 
                        ).ToList();

I chciałbym te elementy wrzucić do bazy przypisując że WZ z klasy WZ_DWS_SITO odpowiada NrWZ z klasy HistoryWZ i tak dalej. Następnie chcę usunąć rekordy z bazy ale to już sobie sam ogarnąłem.


 foreach (var row in skad)
            {
                ent.WZ_DWS_SITO.Remove(row);
            }