- 我得到了RDLC報告
- 存儲在SQL DB中的日期格式是格魯吉亞語。我想在報告中顯示日期爲波斯語。
- 使用Linq我想選擇數據庫的所有字段,另外還有一些新的字段用作波斯日期字段。
我用下面的語法:如何選擇所有字段加上LINQ中的一些新字段?
var invoices = from invoice in dbContext.eve_Invoices
select new
{
invoice.CreatorID,
invoice.DateChange,
invoice.DateCreation,
invoice.DatePrint,
invoice.Discount,
invoice.DiscountPercentage,
invoice.DiscountType,
invoice.Fare,
invoice.ID,
invoice.InvoiceStatus,
invoice.NumberOfItems,
invoice.Packaging,
invoice.PrintID,
invoice.RawPrice,
invoice.RoundOff,
invoice.ServiceCharge,
invoice.ServingType,
invoice.TableID,
invoice.Tax,
invoice.TotalPrice,
invoice.ValidityStatus,
PersianYear = invoice.DateCreation != null ? pc.GetYear((DateTime)invoice.DateCreation) : 0,
PersianMonth = invoice.DateCreation != null ? pc.GetDayOfMonth((DateTime)invoice.DateCreation) : 0,
PersianDay = invoice.DateCreation != null ? pc.GetDayOfMonth((DateTime)invoice.DateCreation) : 0
};
有任何的方式來傳遞發票的各個領域,除了新的領域,如:
var invoices = from invoice in dbContext.eve_Invoices
select new
{
invoice.*,
PersianYear = invoice.DateCreation != null ? pc.GetYear((DateTime)invoice.DateCreation) : 0,
PersianMonth = invoice.DateCreation != null ? pc.GetDayOfMonth((DateTime)invoice.DateCreation) : 0,
PersianDay = invoice.DateCreation != null ? pc.GetDayOfMonth((DateTime)invoice.DateCreation) : 0
};
我也嘗試選擇新的{發票,....}但是它不會導致數據表與第一個數據表相同。
你的第一個語法不會工作,你應該爲你的匿名類型命名參數,我也認爲DateTime的鑄造不會在這裏工作。 – 2012-04-05 22:35:28