我正在使用 LinqToExcel 从 Excel 文件中获取行,然后使用 LINQToSQL 写入 SQLServer。它确实在数据库中创建了记录,但具有空值。我想知道是否需要将 Mac 对象(linqtoexcel)映射到 HSD_TELE_INSTALLs 对象?我不认为我离它太远了,因为它插入了记录。相关代码如下。提前致谢。
//LINQ
var macs = from x in excel.Worksheet<Mac>(sheet)
select x;
//ITERATE WITH LINQ RESULTS
foreach (var x in macs)
{
HSD_TELE_INSTALL myRecord = new HSD_TELE_INSTALL();
db.HSD_TELE_INSTALLs.InsertOnSubmit(myRecord);
db.SubmitChanges();
}
public class Mac
{
public string REGION { get; set; }
public string MACID { get; set; }
public string HOUSEKEY { get; set; }
public string HOUSENUM { get; set; }
public string STREET { get; set; }
public string UNIT { get; set; }
public string ADDRESS2 { get; set; }
public string COMMUNITY { get; set; }
public string STATE { get; set; }
public string ZIPCODE { get; set; }
public string TECHNICIAN { get; set; }
public string JOBNO { get; set; }
public string JOBTYPE { get; set; }
public string CLOSEDATE { get; set; }
public string CLOSETIME { get; set; }
public string COMMENTS { get; set; }
public string MGT { get; set; }
public string COMPLETIONCODE { get; set; }
public string TCRSN { get; set; }