取日期时间CRM 2011 [英] Fetch DateTime CRM 2011

查看:148
本文介绍了取日期时间CRM 2011的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有林一些麻烦日期时间:使用取

Im having some trouble with DateTime: Using Fetch

  <attribute name='new_startdate' groupby='true' dategrouping='day' alias='new_startdate' /> 
  <attribute name='new_enddate' groupby='true' dategrouping='day' alias='new_enddate' /> 
  <attribute name='new_duedate' groupby='true' dategrouping='day' alias='new_duedate' /> 



觉得这是位错那......

Think this is the bit thats Wrong....

  DateTime scheduledstart = ((DateTime)((AliasedValue)a["new_startdate"]).Value);
  tracer.Trace("DateTime 1 Done");
  DateTime enddate = ((DateTime)((AliasedValue)a["new_enddate"]).Value);
  tracer.Trace("DateTime 2 Done");
  DateTime scheduledend = ((DateTime)((AliasedValue)a["new_duedate"]).Value);



然后我添加到新的实体...

Then i add to the new Entity...

    if (scheduledstart != null)
    {
      Activity.Attributes.Add("scheduledstart", scheduledstart);
    }
    if (enddate != null)
    {
       Activity.Attributes.Add("scheduledend", enddate);
    }
    if (scheduledend != null)
    {
     Activity.Attributes.Add("scheduledend", scheduledend);
    }



任何想法如何我写使用AliasedValue从获取的DateTime?或者更好的方式来做到这一点>

Any Ideas How i write the DateTime using AliasedValue from fetch? or a better way to do this>

感谢

推荐答案

谢谢您的帮助,我决定只使用一个单独提取的日期值

Thanks for the help, I have decided to just use a seperate fetch for the date values

string Date_Gather = string.Format(@"         
      <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
         <entity name='new_import'>                       
                 <attribute name='new_enddate'/>         
         </entity>
       </fetch>", entity.Id);

foreach (var b in Date_Gather_result.Entities)
{

   if (b.Attributes.Contains("new_enddate"))
      {
          enddate = ((DateTime)(b["new_enddate"]));
          Entity.Attributes.Add("scheduledend", enddate);
      }
}



还是要谢谢你希望它可以帮助别人

Thanks anyway hope it helps others

这篇关于取日期时间CRM 2011的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆