Code
/// <summary>
/// 根据多条件的查询
/// </summary>
/// <param name="Title">帖子标题</param>
/// <param name="Author">帖子的作者</param>
/// <param name="FBSJStar">开始时间</param>
/// <param name="FBSJEnd">最后时间</param>
/// <param name="IsTop">是否居顶</param>
/// <returns></returns>
public IList<TitleList> SelectTitle(String Title, String Author, String FBSJStar, String FBSJEnd, String IsTop)
{
using(SXWEntities sxw=new SXWEntities())
{
var q = from p in sxw.TitleList
where (string.IsNullOrEmpty(Title) ? true : p.Title.Contains(Title))
&& (string.IsNullOrEmpty(Author) ? true : p.Author.Contains(Author))
&& (string.IsNullOrEmpty(FBSJStar) ? true : p.FBSJ >= (Convert.ToDateTime(FBSJStar)))
&& (string.IsNullOrEmpty(FBSJEnd) ? true : p.FBSJ <= (Convert.ToDateTime(FBSJEnd)))
&& (string.IsNullOrEmpty(IsTop) ? true : p.IsTop == (Convert.ToInt32(IsTop)))
select p;
return q.ToList();
}
}
LINQ to Entities 不识别方法“System.DateTime ToDateTime(System.String)”,因此该方法无法转换为存储表达式。
请各位大侠给点意见, 谢谢!