我正在尝试按特定顺序格式化日期
Time = DateTime.Parse(p.Time.ToString("dd-MM-yyyy HH:mm:ss"))
Time
的数据类型是DateTime
但是我收到了这个错误:
No overload for method "ToString" takes 1 arguments.
p 是我从中获取时间的表的对象。
List<ProductImageMapWrapper> lstpm = new List<ProductImageMapWrapper>();
lstpm = _db.ProductImageMaps.Where(i => i.ClientId == null && i.BrandId == null).Select(p => new ProductImageMapWrapper
{
Time= // Problem here
}
现在,我尝试这样使用它
Time = DateTime.Parse(string.Format("{dd-MM-yyyy HH:mm:ss}", p.Time))
但是我得到了这个错误:
LINQ to Entities does not recognize the method
System.DateTime Parse(System.String)
method, and this method cannot be translated into a store expression.
最佳答案
String Time = Convert.ToDateTime(p.Time).ToString("dd-MM-yyyy HH:mm:ss");
关于c# - 错误 : No overload for method "ToString" takes 1 arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21347353/