- 我收到了一份 RDLC 报告
- 存储在 SQL DB 中的日期格式是格鲁吉亚语。我想在报告中显示日期为波斯语。
- 使用 Linq,我想选择 DB 的所有字段以及一些用作波斯日期字段的新字段。
我使用了以下语法:
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
};
我也尝试了 select new {invoice,....} 但是它不会导致数据表与第一个相同。