You must Sign In to post a response.
  • Category: LINQ

    Update sql table from dynamic table

    I have Dynamic Table created from Excel
    DataTable dt = ExcelToTable(path);

    dt has columns
    1. Updated_Supplier_Remark
    2.Updated_Date

    other table is tblExportOrderdatas with Columns
    1. Supplier_Remark
    2.Date

    I want to update Supplier_Remark with Updated_Supplier_Remark and Date with Updated_Date

    How can i update data from dt to tblExportOrderdatas using LINQ only.

    I am able to do it Using Sql Query but need to do it by Linq only

    Below code is not saving data. Please suggest.

    int sid=Convert.ToInt32(sExportID);

    var objtblInbox = (from m in objLCSEntities.tblExportOrderdatas
    where m.Batch_ID == sid
    select m).ToList<tblExportOrderdata>();



    foreach (var p in objtblInbox)
    {

    var nflplayer = new tblExportOrderdata();
    foreach (DataRow dr in copydt.Rows) // search whole table
    {
    if (!string.IsNullOrEmpty(dr["Updated_Supplier_Remarks"].ToString())) // if not empty
    {

    nflplayer.Supplier_Remark = dr["Updated_Supplier_Remarks"].ToString();

    }
    objLCSEntities.tblExportOrderdatas.AddObject(nflplayer);
    }

    }
    objLCSEntities.SaveChanges();
  • #769831
    You can refer the below post. hope this help you that you are looking for.
    http://stackoverflow.com/questions/8896843/querying-data-using-entity-framework-from-dynamically-created-table


  • Sign In to post your comments