ADO datacontext를 통해 그룹 분류를 사용하는 데이터베이스에서 쿼리를 실행하고 xml 문서를 반환하는 prgm을 작성했습니다. 나는 작업에 XML을 얻을 수 있어요,하지만 XAttribute("pub_id", from p in g select new { p.Pubs_id })
을주고있다 : 아래 ADO Linq to xx
System.Linq.Enumerable+WhereSelectEnumerableIterator`2[Pubs.BookStore+BookResults,<>f__AnonymousType1`1[System.String]]
코드입니다 : 원하는
XDocument xdoc = new XDocument(new XElement("reports",
from b in bookResults
group b by b.Title1 into g
select new XElement("book",
new XAttribute("pub_id", from p in g select new { p.Pubs_id }),
new XElement("Title", g.Key),
from bk in g
select new XElement("Name", new XAttribute("au_id", bk.Au_id), bk.Name))
)
xdoc.Save("Books.xml");
샘플 XML 출력
<reports>
<book pub_id="1389">
<Title>The Busy Executive's Database Guide</Title>
<Name au_id="409-56-7008">Bennet,Abraham</Name>
<Name au_id="213-46-8915">Green,Marjorie</Name>
</book>
<book pub_id="0877">
<Title>Fifty Years in Buckingham Palace Kitchens</Title>
<Name au_id="648-92-1872">Blotchet-Halls,Reginald</Name>
</book>
<book pub_id="0877">
<Title>The Gourmet Microwave</Title>
<Name au_id="722-51-5454">DeFrance,Michel</Name>
<Name au_id="899-46-2035">Ringer,Anne</Name>
</book>
(술집에게 샘플 DB를 사용)
, 난 다음 않았고, 그것은 새가 – SKatz
그룹 B 근무 {b.Title1, b.Pubs_id} g – SKatz
thnks에 도움을 요청하십시오. – SKatz