我无法从adc获取数据以更新到数据库。我正在使用 LINQ2SQL dbml。我没有从 CAPcontext.Log 得到 sql 输出,并且两个表都有主 ID 我觉得这是 LINQ 查询中的连接问题,但在网上找不到任何关于它的信息。有人可以指出我做错了什么吗?
CAP_MDF_dataContextDataContext CAPcontext = new CAP_MDF_dataContextDataContext();
public bool LoadCAPadultdaycare()
{
CAPcontext.Log = Console.Out;
var adc = (from v in CAPcontext.AdultDayCares
join s in CAPcontext.States on v.state equals s.Name
select new CAPadultdaycare {
Avg = v.Avg,
City = v.city,
High = v.High,
Low = v.Low,
StateFullName = v.state,
StateAbbr = s.Code
}).ToList();
foreach (var item in adc)
{ item.City = "some city";
// updating more fields but omitted here
}
CAPcontext.SubmitChanges();
return true;
}
我的 CAPadultdaycare 课程是...
public class CAPadultdaycare
{
public decimal? High { get; set; }
public decimal? Low { get; set; }
public decimal? Avg { get; set; }
public string Zip { get; set; }
public string City { get; set; }
public string StateAbbr { get; set; }
public string StateFullName { get; set; }
}