Access DB表和列表中的每个记录在表中创建一个新列

时间:2014-01-29 13:16:04

标签: c# asp.net linq

传入POSUnitRecords列表。我试图访问表格'记录'在db' EPOSEntities'。 Foreach POS我想在'记录'中添加另一行。表

public static void UpdateDataBase(List<POSUnitRecord> POSs)
        {
            EPOSEntities db = new EPOSEntities();
            var ent = from epos in db.Records
                      where epos.
                      //Columns in 'Records' table are 'Id' & 'Folder'

            foreach (POSUnitRecord pos in POSs)
            {
                //fields in pos are 'Id' & 'Folder'

            }
        }

////////////////////////////////

public class POSUnitRecord
{
    //[Key]
    public int Id { get; set; }
    public virtual string FolderPath { get; set; }

}

1 个答案:

答案 0 :(得分:0)

public static void UpdateDataBase(List<POSUnitRecord> POSs)
        {
            EPOSEntities db = new EPOSEntities();
            var ent = from epos in db.Records;
                      //where epos.
                      //Columns in 'Records' table are 'Id' & 'Folder'

            foreach (POSUnitRecord pos in POSs)
            {
                Record aRecord = new Record();
                aRecord.Id = pos.Id;
                aRecord.Folder = pos.FolderPath
                aRecord.New="put your value";
                ent.Add(aRecord);
            }            
    }