我有一個字符串數組,LINQ查詢:LINQ到由匹配的數量訂貨
/// <summary>
/// Return all the search results
/// </summary>
public static GenericTagEntity[] getSearchResults(int SectionID, string[] Words)
{
GenericTagEntity[] Recs;
using (MainContext db = new MainContext())
{
var q = (
from c in db.tblArticles
join a in db.tblForumAuthors on c.AuthorID equals a.Author_ID
join u in db.tblProfiles on c.AuthorID equals u.UserID
where c.IsDeleted == false
&& c.SectionID == SectionID
select new
{
c.Title,
c.ID,
c.Anchor,
c.Date,
c.Description,
u.EmailAddress,
u.UserID,
a.Username,
c.Body,
comments = (from f in db.tblComments where f.IsDeleted == false && f.Anchor == c.Anchor select new { f.ID }).Count()
});
我想要做的就是修改where
,使返回結果,其中c.Title
或c.Body
包含一個或更多的話。然後我需要通過總匹配(最相關的第一個)排序!
這對我來說似乎非常困難,任何幫助都不勝感激。
我發現這個,但它只是部分有用的,也是SO搜索沒有產生許多結果。 http://msdn.microsoft.com/en-us/library/bb546166.aspx#Y200
您使用的是LINQ提供程序? LINQ to SQL? – svick
@Svick yes linq to sql –