ورود

View Full Version : join فایل xml با دیتابیس



na3er-faraji
دوشنبه 24 مهر 1391, 21:59 عصر
چطور میشه یک فایل xml رو با یک جدول دیتابیس با linq جوین زد. کد من چیزی شبیه کد زیره

public List<ModelAdsReport> SelectAll()
{
XDocument xmlDoc = XDocument.Load(HttpContext.Current.Server.MapPath("./App_Code/Xml/Reports.xml"));
using (var contex = new NavahiModel.NavahiEntities())
{
return (from report in contex.AdsReports
join g in xmlDoc.Descendants("Report") on report.ReportTextId equals g.Element("ReportId").Value
orderby report.AdsReportCreateDate descending
select new ModelAdsReport
{
AdsId = report.AdsId,
Date = report.AdsReportCreateDate,
Ip = report.AdsReportIp,
Title = g.Element("ReportText").Value,
CityId = report.CityId,
}).ToList();
}
}