Hi Cetin,
So following your brilliant PS I got it to work as follows:
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
};
}
So I thought I'd follow your no less brilliant suggestion and came up with this:
using (var context = new PICSEntities(Config.model.SqlServer))
{
XDocument asXmlDocument =
new XDocument(
new XDeclaration("1.0", "utf-8", ""),
new XElement("Parcels",
from p in context.Parcels
join t in context.TransactionDetails on p.Parcels_Id equals t.Parcels_Id
select new XElement("Parcel",
new XAttribute("Parcels_Id", p.Parcels_Id),
new XAttribute("Goods",p.GoodsType.Description),
new XAttribute("Inventory", p.ParcelInventoryType.Description),
new XAttribute("RSReference", p.RSReference),
new XAttribute("Transaction_Nr", t.TransactionHeaders_Id),
new XAttribute("Transaction_Type", t.TransactionHeader.TransactionType.Description),
new XAttribute("Date", t.TransactionHeader.TransactionDate),
new XAttribute("Weight", t.Weight),
new XAttribute("Amount", t.Amount)
)
)
);
using (XmlWriter xw = XmlWriter.Create(@"c:\docs\q.xml"))
{
asXmlDocument.Save(xw);
}
}
But that breaks : System.NotSupportedException: 'Only parameterless constructors and initializers are supported in LINQ to Entities.'
I'm lost here. Don't even now where to start looking.
If things have the tendency to go your way, do not worry. It won't last. Jules Renard.