Microsoft dynamic sdk中join应该注意的问题.

                            QueryExpression queryNextSeq = new QueryExpression { EntityName = "ep_prodoperationsequence" };
                            queryNextSeq.Criteria.AddCondition("ep_prodroutingno", ConditionOperator.Equal, ePOS.ep_ProdRoutingNo.Id);
                            queryNextSeq.Criteria.AddCondition("ep_sequenceno1", ConditionOperator.NotEqual, ePOS.ep_SequenceNo1);
                            queryNextSeq.ColumnSet.AddColumns("ep_prodoperationsequenceid", "ep_sequenceno1", "ep_operationsequence");
                            queryNextSeq.AddOrder("ep_sequenceno1", OrderType.Ascending);

                            queryNextSeq.LinkEntities.Add(new LinkEntity("ep_prodoperationsequence", "ep_operationsequence", "ep_opera                            tionsequence", "ep_operationsequenceid", JoinOperator.Inner));
                            queryNextSeq.LinkEntities[0].Columns.AddColumns("ep_operationsequenceid", "ep_dailywork");//被link实体ep_op                             erationsequence的列
                            queryNextSeq.LinkEntities[0].LinkCriteria.AddCondition("ep_dailywork", ConditionOperator.Equal, true);//给                                     被link实体添加条件

                            EntityCollection ecPrdSeq = service.RetrieveMultiple(queryNextSeq);

 foreach (ep_prodoperationsequence item in ecPrdSeq.Entities)
{
  //取被join实体中的列,字典中必须是实体名称+1,还有就是列数据为null时,要先判断字典中是否包含该键值(就是该列),否则会抛出异常.explain by ldb
  if (item.Attributes.ContainsKey("ep_operationsequence1.ep_dailywork") && item["ep_operationsequence1.ep_dailywork"] != null)
   {
      bool daily  = Convert.ToBeanbool(((AliasedValue)item["ep_operationsequence1.ep_dailywork"]).Value);

   } 
}

 

posted @ 2017-09-01 08:58  longdb  阅读(255)  评论(0编辑  收藏  举报