我创建像比较两个字符串一个简单的搜索:我怎么能比较和SEACH字符串和日期时间C#
articles = _service.ArticleRepository.GetAll(id, new Expression<Func<Article, bool>>[] { x => x.Title.Contains(searchWord) }, a => a.ArticleCategory);
和工程罚款;但我想在日期时间(日期)搜索,我写不同的代码:
articles = _service.ArticleRepository.GetAll(id, new Expression<Func<Article, bool>>[] { x => x.InsertDate ==DateTime.Parse(searchWord) }, a => a.ArticleCategory);
或
articles = _service.ArticleRepository.GetAll(id, new Expression<Func<Article, bool>>[] { x => x.InsertDate.ToString("yyyyMMdd").Contains(searchWord) }, a => a.ArticleCategory);
给我一个错误:
LINQ to Entities does not recognize the method 'System.DateTime Parse(System.String)' method, and this method cannot be translated into a store expression.
From this line int count = _db.Count();
我怎么可以做一些字符串之间的比较和日期作为一个字符串输入日期(以不同的格式,如:2017/8/5或05/05/2017或2017-8-5或...)或甚至输入一个数字(搜索所有日期有一个数字)?