Skip to content

Instantly share code, notes, and snippets.

@kleberksms
Last active April 2, 2016 02:33
Show Gist options
  • Save kleberksms/32ba9f99ba6dabacf154b7de19bb3c15 to your computer and use it in GitHub Desktop.
Save kleberksms/32ba9f99ba6dabacf154b7de19bb3c15 to your computer and use it in GitHub Desktop.
var list = new List<Example>{
new Example{
Id = 1,
Description = "First Level",
Type = 4,
ParentId = 0
},
new Example{
Id = 2,
Description = "Second Level",
Type = 3,
ParentId = 1
},
new Example{
Id = 3,
Description = "Third Level",
Type = 2,
ParentId = 2
},
new Example{
Id = 4,
Description = "Last Level",
Type = 1,
ParentId = 3
},
new Example{
Id = 5,
Description = "First Level",
Type = 4,
ParentId = 0
},
new Example{
Id = 6,
Description = "Second Level",
Type = 3,
ParentId = 5
},
new Example{
Id = 7,
Description = "Third Level",
Type = 2,
ParentId = 6
}
}
Condition => where(c => c.Type = 1)
Expected Result (Array or list result)
[
{
Id = 4,
Description = "Last Level",
Type = 1,
ParentId = 3
},
{
Id = 3,
Description = "Third Level",
Type = 2,
ParentId = 2
},
{
Id = 2,
Description = "Second Level",
Type = 3,
ParentId = 1
},
{
Id = 1,
Description = "First Level",
Type = 4,
ParentId = 0
}
]
@thomasjacksonsantos
Copy link

Cara blz
Eu estou fazendo algo deste genero veja se ajuda...

  string userRoot = userId;

  foreach (var config in Configs.OrderBy(p => p.Level))
  {
    var user = this.UserManager.FindById(userRoot);

    if (user == null || string.IsNullOrEmpty(user.RootId) || ConfigurationManager.AppSettings["SystemId"].ToString() == user.RootId)
    { break; }

    var paymentAssociate = new PaymentsAssociated
    {
      Level = config.Level,
      UserId = user.RootId,
      DateRegister = DateTime.Now
    };

    this.PaymentsAssociatedService.Add(paymentAssociate);
    userRoot = user.RootId;
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment