1.给类型赋值不同

CRM4 plugin给lookup赋值为空 :

Lookup lookupnull = new Lookup();
lookupnull.IsNull = true;
lookupnull.IsNullSpecified = true;
entity.Properties["new_storeroom_areaid"] = lookupnull;

CRM2011 给 EntityReference 赋值为空:

entity["new_storeroom_areaid"] = null;

2.单表查询,返回Entity

CRM4.0 :

private DynamicEntity GetNewPrInfo(Guid NewPrID)//根据GUID查询某字段
{
ColumnSet colSet = new ColumnSet(NewPrInfo.EntityName);
colSet.AddColumn(NewPrInfo.AttributeName_Assigner);
colSet.AddColumn(NewPrInfo.AttributeName_AssignNode); TargetRetrieveDynamic target = new TargetRetrieveDynamic();
target.EntityId = NewPrID;
target.EntityName = NewPrInfo.EntityName; RetrieveRequest request = new RetrieveRequest();
request.ColumnSet = colSet;
request.ReturnDynamicEntities = true;
request.Target = target; RetrieveResponse response = (RetrieveResponse)this.crmService.Execute(request);
DynamicEntity PromotionPe = (DynamicEntity)response.BusinessEntity;
return PromotionPe;
}

CRM2011:

Entity accEntity = service.Retrieve(“new_test”, new_testid, new ColumnSet("字段1", "字段2"));//根据GUID,查询实体new_test的字段1和字段2的值。
Entity accEntity = service.Retrieve(entityName, entityId, new ColumnSet(true));//根据GUID,查询实体new_test的所有字段。

3.初始化CRM组织服务

CRM4:

CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = ;
token.OrganizationName = "AdventureWorksCycle"; CrmService service = new CrmService();
service.Url = ""http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

CRM2011:

IFD 的服务前面的段必须是https,不分内部和外部。

Uri orgServiceUri = new Uri("https://192.168.1.101/MicrosoftDynamicCRM/XRMServices/2011/Organization.svc");
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = CRMUserName;
credentials.UserName.Password = CRMUserPassword;
OrganizationServiceProxy crmServiceProxy = new OrganizationServiceProxy(orgServiceUri, null, credentials, null);
crmService = (IOrganizationService)crmServiceProxy; . on-premise 内部部署(AD认证),,初始化WebService时的方式如下: 服务前面的段可以是https,也是可以http 如果没有路由映射 外网是访问不了 只能内网访问 Uri organizationUri = new Uri("http://192.168.1.101/MicrosoftDynamicCRM/XRMServices/2011/Organization.svc");
IServiceConfiguration<IOrganizationService> orgConfigInfo = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(organizationUri);
var Orgcreds = new ClientCredentials();
Orgcreds.Windows.ClientCredential = new System.Net.NetworkCredential("administrator", "admiN123", "DynamicCRM.com");
OrganizationServiceProxy _serviceproxy = new OrganizationServiceProxy(orgConfigInfo, Orgcreds);
return (IOrganizationService)_serviceproxy; 这样子也可以: Uri orgServiceUri = new Uri(Config.CrmWebServiceUrl);
var credentials = new ClientCredentials();
credentials.Windows.ClientCredential = new System.Net.NetworkCredential(Config.CrmServerAccount, Config.CrmServerPSW, Config.CrmServerDomain);
OrganizationServiceProxy _serviceproxy = new OrganizationServiceProxy(orgServiceUri, null, credentials, null);
return (IOrganizationService)_serviceproxy;

4.返回多个实体

CRM4:

// Create a column set holding the names of the columns to be retrieved.
ColumnSet cols = new ColumnSet();
cols.Attributes = new string [] {"name", "accountid"}; // Create the query object.
QueryByAttribute query = new QueryByAttribute();
query.ColumnSet = cols;
query.EntityName = EntityName.account.ToString(); // The query will retrieve all accounts whose address1_city is Sammamish.
query.Attributes = new string [] {"address1_city"};
query.Values = new string [] {"Sammamish"}; // Execute the retrieval.
BusinessEntityCollection retrieved = service.RetrieveMultiple(query);

CRM2011:

方法一:

string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' aggregate='true'>
<entity name='new_po_exp_detail'>
<attribute name='new_exp_amount' alias='new_exp_amount_sum' aggregate='sum' />
<attribute name='new_submit_amout' alias='new_submit_amout_sum' aggregate='sum' />
<attribute name='new_expense_category' alias='new_expense_category' groupby='true' />
<filter type='and'>
<condition attribute='statecode' operator='eq' value='0' />
</filter>
<link-entity name='new_po' from='new_poid' to='new_po_exp_detail' alias='ab'>
<filter type='and'>
<condition attribute='statecode' operator='eq' value='0' />
<condition attribute='new_po_status' operator='in'>
<value>5</value>
<value>7</value>
</condition>
<condition attribute='new_promotion_pe' operator='eq' value='" + new_promotion_peId + @"' />
</filter>
</link-entity>
</entity>
</fetch>";
EntityCollection entitycols = service.RetrieveMultiple(new FetchExpression(fetchxml));

方法二:

QueryByAttribute query = new QueryByAttribute("new_categorytate");
query.ColumnSet = new ColumnSet("new_categorytateid");
query.AddAttributeValue("statecode", );
query.AddAttributeValue("new_sn", new_sn);//产品品类编号
EntityCollection encols = service.RetrieveMultiple(query);

Dynamics CRM4.0 和 Dynamics CRM2011 Plugin 实现一样的功能的方法的比较的更多相关文章

  1. Microsoft Dynamics CRM4.0编程---说明

    Introduction(说明) If your organization has customers, you need a software system to help you manage y ...

  2. Microsoft Dynamics CRM4.0 和 Microsoft Dynamics CRM 2011 JScript 方法对比

    CRM 2011 如果需要再IE里面调试,可以按F12在前面加上contentIFrame,比如 contentIFrame.document.getElementById("字段" ...

  3. Microsoft Dynamics CRM4.0 JScript 过滤lookup 出现 Microsoft Dynamics CRM 窗口无法打开,可能已被弹出窗口阻止程序所阻止。

    一.现象:JScript过滤lookup字段,选择lookup字段出现下图的情况: 出现:Microsoft Dynamics CRM 窗口无法打开,可能已被弹出窗口阻止程序所阻止.请将这台Micro ...

  4. Microsoft Dynamics CRM4.0 创建单据的时候,自动生成单据编号的通用方法

    一.新建两个实体,具体如下: 单据流水号(new_maxbillcode) 显示名称 名称 类型 格式 最大长度 需求级别 IME模式 备注 名称 new_name nvarchar 文本 100 业 ...

  5. Dynamics CRM 4.0升级Dynamics CRM 2013后全局Ribbon的修改

    最近在为一个客户在Dynamics CRM 4.0到Dynamics CRM 2013的升级,升级之后发现原来在Dynamics CRM 4.0中定义的全局Ribbon按钮像牛皮癣一样,在每个实体页面 ...

  6. Dynamics CRM9.0更新了Chrome后菜单按钮变形

    前段时间Chorme更新后Dynamics CRM9.0的系统菜单样式变的很难看 具体修改方法如下: 找到Dynamics CRM安装目录C:\Program Files\Microsoft Dyna ...

  7. 转载文章:Windows Azure 基础结构服务上的 Microsoft Dynamics NAV 和 Microsoft Dynamics GP!

    Windows Azure 基础结构服务(虚拟机和虚拟网络)可提供按需基础结构,该基础结构可进行伸缩以适应不断变化的业务需求.无论您是在虚拟机中创建新应用程序,还是运行现有应用程序,我们都将按分钟收费 ...

  8. Discuz 7.0版块横排显示版块图标和版块简介的方法

    Discuz 7.0版块横排显示版块图标和版块简介的方法 最近很多朋友咨询Discuz论坛设置论坛版块横排后,如何设置显示版块图标和简介的问题. 一.显示板块图标 找到templates\defaul ...

  9. 转:JMeter监控内存及CPU ——plugin插件监控被测系统资源方法

    JMeter监控内存及CPU ——plugin插件监控被测系统资源方法 jmeter中也可以监控服务器的CPU和内存使用情况,但是需要安装一些插件还需要在被监测服务器上开启服务. 1.需要的插件准备 ...

随机推荐

  1. [转]Why Not Paxos

    http://blog.csdn.net/cszhouwei/article/details/38374603 Why Not Paxos Paxos算法是莱斯利·兰伯特(LeslieLamport, ...

  2. 深入分析Php处理浮点数的问题

    下文来为各位介绍Php处理浮点数的问题了,如果各位在使用过程中碰到这些问题我们可以一起来看看,希望文章对各位有帮助 公司要对产品价格做调整,因为做的外贸商城,所以价格要和国际接轨.比如国外的价格展示方 ...

  3. magento关于站点搬家,换空间

    1,先把原来空间的文件全部压缩后(有些不要的就不要压缩)下载下来,然后传到新空间去,注意下载下来后核对一下是否大小一样,建议使用ftp工具下载, 2,同样把原来空间的数据库打包下来,再在新空间创建一个 ...

  4. latex 小结

    1 no file .bbl http://blog.csdn.net/zhedasuiyuan/article/details/9223637 另外,你可能有多个 .bbl.目前的做法是,在控制台上 ...

  5. 【转】BAT 延迟变量

    延迟环境变量在bat里是重中之重,虽然前面说过,熟练应用for才算会写批处理,但如果不懂延迟环境变量的话,那么你就只能写出简单的批处理,而for语句也不能发挥最大的作用. 延迟环境变量在cmd下默认是 ...

  6. maker 2008年发表在genome Res

    http://gmod.org/wiki/MAKER_Tutorial 简单好用 identify repeats, to align ESTs and proteins to the genome, ...

  7. rsync 使用示例

    导读 Rsync(remote sync) 是用于同步某一位置文件和目录到另一位置的有效方法.备份的位置可以在本地服务器或远程服务器.本站之前亦有介绍rsync的安装配置和教程,详看<rsync ...

  8. coreseek(sphinx)安装2(mysql数据源配置和测试)

    Windows操作系统下 mysql数据源配置: 主要步骤:  配置mysql数据源配置文件->生成索引->开启索引   (三步) coreseek\etc\csft_mysql.conf ...

  9. 使用isInEditMode解决可视化编辑器无法识别自定义控件的问题

    如果在自定义控件的构造函数或者其他绘制相关地方使用系统依赖的代码, 会导致可视化编辑器无法报错并提示:Use View.isInEditMode() in your custom views to s ...

  10. 增加mvc:resources后访问不了注解配置的controller的问题

    刚开始没有配置mvc:resourcescontroller能够正确访问,但是由于web.xml使用/拦截了所有的请求,所以静态资源访问不上增加mvc:resources之后,静态资源是能访问上了,但 ...