none
How to enumerate EntityCollection?

    Question

  • Hi All,

    I would like to iterate through EntityCollection instead of using for loop. Is there a way to achieve something like this?

    Thanks in advance for your reply.

    Thanks

    Vikram

    Tuesday, October 15, 2013 1:47 AM

All replies

  • Use LINQ on EntityCollection.Entities
    Tuesday, October 15, 2013 1:50 AM
  • Hi

    In C# code, you can loop the record this way

    foreach(var entity in entityCollection.Entities)
    {
       //your code logics here
    }

    In JavaScript, you can still loop your record, though you will need to convert the returned result in a JSON object to make your life a bit easier.

    Regards,

    Jaimie

    Tuesday, October 15, 2013 2:33 PM
  • HI,

    Try this:

    foreach(var entityRecord in entityCollection.Entities)

    {

    }

    Regards,

    Rameshwari

    • Proposed as answer by RameshwariSah Tuesday, October 15, 2013 6:50 PM
    Tuesday, October 15, 2013 6:50 PM
  • Hi Vikram,

    You can iterate the EntityCollection using Foreach loop in two ways

    Approach 1:

    foreach(var entity in entityCollection.Entities)
    {
       //your code logics here
    }

    Approach 2:

    foreach(Entity entity in entityCollection.Entities)
    {
       //your code logics here
    }



    Warm Regards, Suresh Kumar D

    Wednesday, October 16, 2013 2:17 AM