Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Fetch XML in C# using Xrm.SDK

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,


In CRM 4.0 and CRM 11 there is function Fetch() to get data from the XML, we can do that using Crm.SDK but in Xrm.SDK there is no function available name Fetch().


I have used Odata with JavaScript, but i don't know how to use it with C#.

Please Help...!!!

Thanks

*This post is locked for comments

  • suresh maurya Profile Picture
    suresh maurya 630 on at
    RE: Fetch XML in C# using Xrm.SDK

    For testing of FetchXML, you can test here online http://msxrmtools.com

  • Waqar Sohail Profile Picture
    Waqar Sohail on at
    RE: Fetch XML in C# using Xrm.SDK

    Hi You can also use Query Expression to retrieve Data in C#.

    QueryExpression query = new QueryExpression("EntityLogicalName");
    query.ColumnSet = new ColumnSet("column1", "coumn2");
    // Or retrieve All Columns
    //query.ColumnSet = new ColumnSet(true);
    
    query.Criteria.Conditions.Add(new ConditionExpression("status", ConditionOperator.Equal, 1));
    
    var result = service.RetrieveMultiple(query);
    
    foreach (var entity in result.Entities)
      {
      // Get the Columns from the Entity Obj Like this. Depands on type of the Column. 
       string entityColumn1 = entity.Contains("column1") ? entity["column1"].ToString() : string.Empty;
      }

    Regards

  • Verified answer
    Aileen Gusni Profile Picture
    Aileen Gusni 44,524 on at
    RE: Fetch XML in C# using Xrm.SDK

    Hi Chirag,

    You can use

    RetrieveMultiple(new FetchExpression(fetchxml)) function.

    But, different from .Fetch() in CRM 4.0, both input and output are string XML.

    in CRM 2011 and CRM 2013 we can use XML as input using that FetchExpression(fetchxml), but it will return EntityCollection()

    See this:

    msdn.microsoft.com/.../gg328117.aspx

    msdn.microsoft.com/.../gg328332.aspx

    Hope this helps!

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,820 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,514 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans