I created a data model using EntityFramework and with the help of appropriate queries I get the data from the database. I would like the button to be able to delete all documents that will be marked as WZ (document number). I created the HistoryWZ class which will be a new table storing the story and I would like to use the LINQ query to extract data from one table, pass it to the second table and delete it from the first table.
Using LINQ i got list of data:
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 new
{
d.WZ,
d.KUNNR
}).ToList();
I would like to use the created class to pass data to the table using LINQ ofc.
My HistoryWZ class :
ublic class HistoryWZ
{
public string NrWZ { get; set; }
public string ODBIORCA { get; set; }
public string DataWZ { get; set; }
public string 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; }
public string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
}
Are Table A
and Table B
of the same structure? If so, it sounds like you've got a problem at the database schema level as its not properly normalised. If they are not, then:
DbContext
. Table A
and place in Table B
(We will call this Table A Object
). Table B Object
. Table B Object
with the data from the Table A Object
. Table B Object
to the context with DbContext.Add(TableBObject)
DbContext.Remove(TableAObject)
and commit the transaction
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.