C# CRM-Linq与属性值

C# CRM-Linq与属性值,c#,linq,C#,Linq,我有一个关于CRM中LINQ和属性的快速问题。我对我试图编写的这段代码有一些问题 //Create query to get the related regular rates var rateres = from r in ServiceContext.CreateQuery("pafo_rate") where r["pafo_assignmentid"].Equals(entity.Id) select r; //Excepti

我有一个关于CRM中LINQ和属性的快速问题。我对我试图编写的这段代码有一些问题

//Create query to get the related regular rates
var rateres = from r in ServiceContext.CreateQuery("pafo_rate")
              where r["pafo_assignmentid"].Equals(entity.Id)
              select r;



//Exception Rate - excluding pto
//   var eateres = from er in ServiceContext.CreateQuery("pafo_exceptionrate")
//                 where er["pafo_assignmentid"].Equals(entity.Id) && er["pafo_assignmentid"] != ""                                  
//                 select er;

foreach (var r in rateres)
{
      Entity e = (Entity)r;
      // e["pafo_billrate"] = newbillupdate + payupdate;
      // test = (decimal)e.Attributes["pafo_payrate"]; \\ <-- How do you fix?  
      // test = 6;
      e["pafo_payrate"] = (newpayupdate + test);
      // ServiceContext.Attach(e);
      ServiceContext.UpdateObject(e);
      ServiceContext.SaveChanges();
}
//创建查询以获取相关的常规费率
var rateres=来自ServiceContext.CreateQuery中的r(“pafo_rate”)
其中r[“pafo_assignmentid”]等于(entity.Id)
选择r;
//异常率-不包括pto
//var eaters=来自ServiceContext.CreateQuery(“pafo\U异常率”)中的er
//其中er[“pafo_assignmentid”]等于(entity.Id)&&er[“pafo_assignmentid”!=""                                  
//选择er;
foreach(比率中的var r)
{
实体e=(实体)r;
//e[“pafo_billrate”]=纽比勒更新+支付更新;

//test=(decimal)e.Attributes[“pafo_payrate”];\\n我不确定这是否与您的linq查询有关。但是您是否尝试过包装
ServiceContext.SaveChanges();
中尝试…捕获
语句并检查内部异常等详细信息?我使用了不同的方法使用上下文课程。我不确定这是否与linq查询有关。但是您是否尝试过包装
ServiceContext.SaveChanges()
中尝试…捕获
语句并检查内部异常等详细信息?我使用了不同的方法使用上下文课程。