我有一個實體在我的上下文中,「POST」,並執行以下操作:如何在Entity Framework 6中執行搜索?
String[] keywords = new String[] { "Car", "Yellow" };
我如何可以搜索所有標題中包含了2個字的帖子嗎?
注意:關鍵字可以有1到4個單詞。
員額實體如下:
public class Post {
public Int32 Id { get; set; }
public DateTime Created { get; set; }
public String Text { get; set; }
public String Title { get; set; }
public DateTime Updated { get; set; }
} // Post
,這裏是我的SQL:
create table dbo.Posts
(
Id int identity not null
constraint PK_Posts_Id primary key clustered (Id),
Created datetime not null,
[Text] nvarchar (max) not null,
Title nvarchar (120) not null,
Updated datetime not null
);
我一直在SQL看着喜歡,但什麼是實體框架中的相同呢?
我需要全文搜索嗎?它在SQL Server 2012 Express中可用嗎?
UPDATE
繼haim770建議我嘗試了以下內容:
Context context = new Context();
String[] words = new String[] { "Car" };
List<Post> posts = context.Posts.Where(x => words.Contains(x.Title).ToList();
沒有帖子用這個...任何想法回來了?
謝謝你, 米格爾
請張貼的例子你上下文和郵政實體。 – Maess