You would have to create a custom stored procedure to return only the categories that don't have a parent id (hence root/parent categories). This custom stored procedure would be automatically generated into the entity service provided you configured the template correctly. I wouldn't recommend this for such a simple query. Your other option is to use a <Entity>Query object with the Find method of the service like this:
TList<Category> categories;
CategoryQuery query = new CategoryQuery();
CategoryService service = new CategoryService();
query.AppendIsNull(CategoryColumn.CategoryParentID);
categories = service.Find(query.GetParameters(), "CategoryName"); // Second param is the sort
service.DeelLoad(categories, false, DeepLoadType.IncludeChildren, typeof(TList<Categories>));
Now you have a list of root categories where each category has a child collection of the child categories called "CategoryCollection"
You can loop through them like this:
foreach(Category parent in categories)
{
Console.WriteLine(parent.CategoryName);
foreach(Category child in parent.CategoryCollection)
{
Console.WriteLine("\t" + child.CategoryName);
}
}