Код: Выделить всё
SELECT d.domain_id, d.name, sd.subdomain_id, sd.name, sd.[description]
FROM [myDB].SubDomains sd INNER JOIN [myDB].Domains d
ON d.domain_id = sd.domain_id ORDER BY d.[name], sd.[name]
Код: Выделить всё
domain_id | name | subdomain_id |name | description
1 A 11 AB AB description
1 A 12 AC AC description
2 B 21 BA BA description
Код: Выделить всё
// This is Domain Mapping as we can have list of domains
public class HigherLevel
{
public List Domains { get; set; }
}
public class DomainModel
{
public int Id { get; set; }
public string Name { get; set; }
public List SubDomains { get; set; }
}
public class SubDomainModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
Код: Выделить всё
HigherLevel: {
domains: [{
id:,
name:,
subdomains: [{ id: ,name: , description: }]
},
{ id:,
name:,
subdomains: [{ id: ,name: , description: },
{ id: ,name: , description: }]
},
id:,
name:,
subdomains: [{ id: ,name: , description: }]
},
{ id:,
name:,
subdomains: [{ id: ,name: , description: },
{ id: ,name: , description: }]
}]
}
Я хотел бы знать, как я могу вернуть результат SQL для сопоставления с моделью, чтобы что он может поместить результат во вложенный список доменов-> субдоменов.
Подробнее здесь: https://stackoverflow.com/questions/729 ... sted-model
Мобильная версия