此类代码有什么问题
public List<SearchItem> Search(string find)
{
return (from i in _dataContext.News where i.Text.Contains(find) select new SearchItem { ControllerAction = "test", id = i.Id.ToString(), LinkText = "test" }).ToList();
}
public struct SearchItem
{
public string ControllerAction;
public string LinkText;
public string id;
}
答案 0 :(得分:2)
new SearchItem() {...}
//没有.ToList()或者你不需要这个类(s / b是一个带有属性get / set的类),你可以说新的