Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XML Anonymous Types
Message
De
26/03/2017 08:18:41
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
ASP.NET
Catégorie:
XML
Versions des environnements
Environment:
C# 5.0
OS:
Windows 10
Network:
Windows Server 2016
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01649231
Message ID:
01649343
Vues:
56
Make it local in between:
using (var context = new PICSEntities(Config.model.SqlServer))
{
	var q = from p in context.Parcels
			join t in context.TransactionDetails on p.Parcels_Id equals t.Parcels_Id
			select new
			{
				Parcels_Id = p.Parcels_Id,
				Goods = p.GoodsType.Description,
				Inventory = p.ParcelInventoryType.Description,
				RSReference = p.RSReference,
				Transaction_Nr = t.TransactionHeaders_Id,
				Transaction_Type = t.TransactionHeader.TransactionType.Description,
				Date = t.TransactionHeader.TransactionDate,
				Weight = t.Weight,
				Amount = t.Amount
			};


XDocument asXmlDocument =
new XDocument(
	new XDeclaration("1.0", "utf-8", ""),
		new XElement("Parcels",
		  from p in q.AsEnumerable()
		  select new XElement("Parcel",
			  new XAttribute("Parcels_Id", p.Parcels_Id),
			  new XAttribute("Goods", p.Goods),
			  new XAttribute("Inventory", p.Inventory),
			  new XAttribute("RSReference", p.RSReference),
			  new XAttribute("Transaction_Nr", p.Transaction_Nr),
			  new XAttribute("Transaction_Type", p.Transaction_Type),
			  new XAttribute("Date", p.Date),
			  new XAttribute("Weight", p.Weight),
			  new XAttribute("Amount", p.Amount)
			)
		)
	);
	using (XmlWriter xw = XmlWriter.Create(@"c:\docs\q.xml"))
	{
		asXmlDocument.Save(xw);
	}
}
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform