How do I convert SQL's convert(varchar,datefield,106)
to LINQ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can get a string representation of a date by using ToString()
myDate.ToString()
and a date representation of a string by parsing it.
DateTime.Parse(myDateString)
You just need to include your conversion in your select clause.
from myRecord in myDataContext.MyTable
select new {myStringDate = myRecord.myDate.ToString()};
标签:
linq-to-sql