Nested object to hierarchical object list
var sublayers = data.Where(i =&gt; i.ParentId == layer1.Id &amp;&amp; i.ParentId !=0);  



you should let the operators some room to breathe. Adding a space after = makes your code more readable.  

Bug alert  

In the above query you are filtering for i.ParentId != 0 and later on you have the condition &amp;&amp; layer.ParentId ==0 so your hierarchy wil remain empty.  




var enumerable = sublayers as Layer[] ?? sublayers.ToArray();  



This makes me just wonder. What sense does it have to convert the IEnumerable&lt;Layer&gt; to an array if the next thing you do is iterating over the items by using a foreach loop ? 


var layer1 = layer;  



this isn't necessary at all, it is sufficient to use the layer inside linq expression.  



You should always use braces {} for single command if statements to make your code less error prone. If you decide to no use them, please don't come back whining that you have a bug you can't find (humour btw.).



Integrating the mentioned points will lead to  

public IList&lt;Layer&gt; GetLayers()
{
    IList&lt;Layer&gt; data = Db.GetLayers();

    IList&lt;Layer&gt; hierarcy = new List&lt;Layer&gt;();

    foreach (var layer in data)
    {

        var sublayers = data.Where(i =&gt; i.ParentId == layer.Id &amp;&amp; i.ParentId != 0);

        if (sublayers.Any())
        {
            hierarcy.Add(layer);
        }
        foreach (var sublayer in sublayers)
        {
            layer.ChildLayers.Add(sublayer);
        }
    }

    return hierarcy;
}  





public class Layer
{
    public int Id { get; set; }
    public int ParentId { get; set; }
    public string Name { get; set; }
    public IList&lt;Layer&gt; ChildLayers { get; set; }

    public Layer()
    {
        ChildLayers = new List&lt;Layer&gt;();
    }
}  



You shouldn't expose the ChildLayers property setter to the public. If someone comes along setting it to null you would be lost. 

You should just change it to  

public IList&lt;Layer&gt; ChildLayers { get; private set; }  


Otherwise using autoimplemented properties, as long as you don't need validation in the setters , is the way to go.