Contenttypeのプロパティを持つ次のエンティティがありますbyte[]。
public class Post
{
[Column(TypeName = "varbinary(max)")]
[Required]
public byte[] Content { get; set; }
public string ContentType { get; set; }
}
モデル ビルダーのコンテンツ タイプ:
modelBuilder.Entity<Post>()
.Property(p => p.ContentType)
.HasComputedColumnSql("'.html'");
移行:
migrationBuilder.Sql("CREATE FULLTEXT CATALOG ft_catalog AS DEFAULT", true);
migrationBuilder.Sql(@"CREATE FULLTEXT INDEX ON dbo.Posts([Content] TYPE COLUMN ContentType) KEY INDEX PK_Posts", true);
EF.Functions.FreeTextpropertyReferencestringとstring を取りますfreeText。
ここでは、列「コンテンツ」を取得した文字列として渡しましたThe expression passed to the 'propertyReference' parameter of the 'FreeText' method is not a valid reference to a property. The expression should represent a reference to a full-text indexed property on the object referenced in the from clause。
IQueryable<DataSets.Post> query = db.Posts;
query = query.Where(k => EF.Functions.FreeText("Content", model.keyword));
それから、私は周りを見回してそれを見つけてパラムでEF.Property使用しました。propertyReferenceFailed to convert parameter value from a String to a Byte[]
query = query.Where(k => EF.Functions.FreeText(EF.Property<string>(k, "Content"), model.keyword));
次の SQL クエリは、データベースに対して完全に機能します。
select ID,Title,Description from Posts where FREETEXT(Content,'wolf')