我有一个产品清单,必须由父母订购,然后是父母的所有孩子,然后是下一个父母,等等.
Product One
Child One
Child Two
Product Two
Child One
Run Code Online (Sandbox Code Playgroud)
这些产品都在一个带有父ID字段的表中,子产品具有父ID,但父项可以具有空父项(表示该产品是顶级产品)

我在考虑以下内容:
var list = GetProductList();
var newList = new List<ProductDTO>();
var parents = from p in list
where p.Parent == null
select p.Id;
foreach (var parent in parents)
{
var tempList = new List<ProductDTO>();
tempList.Add(list.FirstOrDefault(x => x.Id == parent));
tempList.AddRange(list.Where(x => x.Parent == parent).OrderBy(x => x.Id));
newList.AddRange(tempList);
}
Run Code Online (Sandbox Code Playgroud)
关于我怎么做这个有点清洁的任何建议?
我正在尝试访问存储在Windows Azure中的私有容器中的Blob.容器具有共享访问签名,但是当我尝试访问blob时,我得到StorgeClientException"服务器无法验证请求.请确保正确形成Authorization标头,包括签名".
创建容器并上传blob的代码如下所示:
// create the container, set a Shared Access Signature, and share it
// first this to do is to create the connnection to the storage account
// this should be in app.config but as this isa test it will just be implemented
// here:
// add a reference to Microsoft.WindowsAzure.StorageClient
// and Microsoft.WindowsAzure.StorageClient set up the objects
//storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["ConnectionString"]);
blobClient = storageAccount.CreateCloudBlobClient();
// get a reference tot he container for the shared access …Run Code Online (Sandbox Code Playgroud)