locked
Loop in C# RRS feed

  • Question

  • I would like to write a loop in C# to go though all Accounts in MS CRM

    What the condition for this?


    hussain
    Wednesday, November 10, 2010 7:35 AM

Answers

  • Hi,

    It would be something like that:

    // Instantiate CRM service object
    // (that code goes here)
    
    // Instanciate QueryExpression object to be supplied to service method
    QueryExpression query = new QueryExpression();
    
    // set QueryExpression properties
    query.EntityName = EntityName.account.ToString();
    query.ColumnSet = new AllColumns();
    
    BusinessEntityCollection colBE = crm.RetrieveMultiple(query);
    
    foreach (BusinessEntity be in colBE.BusinessEntities)
    {
     account objAccount = (account)be;
    
     // do something
    }
    

    Regards,
    Paradise lies at the feet of thy mother. - Prophet Mohammed (PBUH)
    • Marked as answer by Hussain Saffar Wednesday, November 10, 2010 8:21 AM
    Wednesday, November 10, 2010 8:09 AM

All replies

  • Hi,

    It would be something like that:

    // Instantiate CRM service object
    // (that code goes here)
    
    // Instanciate QueryExpression object to be supplied to service method
    QueryExpression query = new QueryExpression();
    
    // set QueryExpression properties
    query.EntityName = EntityName.account.ToString();
    query.ColumnSet = new AllColumns();
    
    BusinessEntityCollection colBE = crm.RetrieveMultiple(query);
    
    foreach (BusinessEntity be in colBE.BusinessEntities)
    {
     account objAccount = (account)be;
    
     // do something
    }
    

    Regards,
    Paradise lies at the feet of thy mother. - Prophet Mohammed (PBUH)
    • Marked as answer by Hussain Saffar Wednesday, November 10, 2010 8:21 AM
    Wednesday, November 10, 2010 8:09 AM
  • Thank youuuuuuuu
    hussain
    Wednesday, November 10, 2010 8:22 AM