How to disable CRM 2011 Xrm caching?

耗尽温柔 提交于 2019-12-23 21:12:11

问题


I have problem with crm 2011 caching. I don't need it, but I don't know how to disable it.

First I generate this:

CrmSvcUtil.exe /codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration" /out:Outputcs /url:https://crmaddress/XRMServices/2011/Organization.svc /username:usr/password:pw /namespace:ns/serviceContextName:XrmServiceContext

then I have the following code:

   private XrmServiceContext _crmService;

    public CrmWS()
    {
        CrmConnection _connection = new CrmConnection();
        _connection.ServiceUri = new Uri("https://url");

        ClientCredentials credentials = new ClientCredentials();
        credentials.Windows.ClientCredential = new NetworkCredential("1","2","3"); 
        _connection.ClientCredentials = credentials;
        _connection.ClientCredentials.UserName.UserName = "1";
        _connection.ClientCredentials.UserName.Password = "2";
        _crmService = new XrmServiceContext(_connection);

       var l = _crmService.EntitySet.where(m => m.name == "a").ToList();
    }

What should I do to turn off caching?


回答1:


Specify the service in your configuration file:

  <microsoft.xrm.client>   
    <services>
      <add name="Xrm" type="Microsoft.Xrm.Client.Services.OrganizationService, Microsoft.Xrm.Client"/>
    </services>
  </microsoft.xrm.client>



回答2:


Another bypass I found which can be used, its not perfect and people might give me bad reviews.

But you can always use a query which always changes with a random number or other random code:

Random r = new Random();
int rInt = r.Next(-100000000, 100000000);
var l = _crmService.EntitySet.where(m => m.name == "a" &&  m.name!=rInt.ToString()).ToList();


来源:https://stackoverflow.com/questions/8309197/how-to-disable-crm-2011-xrm-caching

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!