我想在Linq查询中将公历日期转换为Shamsi
这是我的查询
Contex = new RfidReaderEntities1();
var selectall = from myreads in Contex.V_DriverWithReadTags select new { myreads.RfidTagId, myreads.CarType, myreads.Plate, myreads.VisiteDate, myreads.Lname,myreads.shamsidate};
dataGridView1.DataSource = selectall.ToList();
我想将myreads.VisiteDate
转换为Shamsi日期。
答案 0 :(得分:0)
首先下载FarsiLibrary.Utils
因为它将Gregorian转换为Shamsi而没有任何错误将其DLL
文件添加到您的项目中以获取更多信息Here。
然后试试这个:
var selectall = from myreads in Contex.V_DriverWithReadTags select new {
RfidTagId = myreads.RfidTagId,
CarType = myreads.CarType,
Plate = myreads.Plate,
VisiteDate = PersianDateConverter.ToPersianDate(myreads.VisiteDate),
Lname = myreads.Lname,
shamsidate = myreads.shamsidate
};
答案 1 :(得分:0)
Contex = new RfidReaderEntities1();
var selectall = from myreads in Contex.V_DriverWithReadTags select new {
RfidTagId = myreads.RfidTagId,
CarType = myreads.CarType,
Plate = myreads.Plate,
VisiteDate = PersianDateConverter.ToPersianDate((DateTime)myreads.VisiteDate),
// VisiteDate = myshamsifun.GetShamsiDateTime((DateTime)myreads.VisiteDate),
Lname = myreads.Lname,
};
dataGridViewlisttoday.DataSource = selectall.ToList();