Closed Martin-DC closed 7 years ago
resolved with adding container.Configuration.UseDatabaseNullSemantics = true; close the issue.
请尝试
using (var container = new ProductSystemContainer(1)) {
container.Configuration.UseDatabaseNullSemantics = true;
var text = FullTextSearchModelUtil.Contains("三星 iphone5",true);
var q = container.Sku.Where(c => (c.Title+c.Keywords).Contains(text));
container.Database.Log = Console.WriteLine;
var a = q.ToList();
Assert.IsTrue(a.Count>1);
}
Hi when I do single column search it works fine, but when I do multiple search search coding like:
using (var container = new ProductSystemContainer(1)) { var text = FullTextSearchModelUtil.Contains("三星 iphone5",true); var q = container.Sku.Where(c => (c.Title+c.Keywords).Contains(text)); container.Database.Log = Console.WriteLine; var a = q.ToList(); Assert.IsTrue(a.Count>1); }
it shows error测试方法 ProductTest.SqlServerFullTextTest.FullTextTest 引发了异常: System.Data.Entity.Core.EntityCommandExecutionException: 执行命令定义时出错。有关详细信息,请参阅内部异常。 ---> System.Exception: FTS was not replaced on: SELECT [Extent1].[Id] AS [Id],
[Extent1].[Title] AS [Title], [Extent1].[Keywords] AS [Keywords], [Extent1].[Description] AS [Description],
[Extent1].[Created] AS [Created], [Extent1].[LastModified] AS [LastModified] FROM [dbo].[Sku] AS [Extent1] WHERE [Extent1].[Title] + CASE WHEN ([Extent1].[Keywords] IS NULL) THEN N'' ELSE [Extent1].[Keywords] END LIKE @plinq0 ESCAPE N'~' 在 Fissoft.EntityFramework.Fts.FtsInterceptor.ReplacePropertyWithParameterKeyword(FtsSetting setting, String flag, String text, DbCommand cmd) 在 Fissoft.EntityFramework.Fts.FtsInterceptor.ReplaceProperty(DbCommand cmd, String flag) 在 Fissoft.EntityFramework.Fts.FtsInterceptor.RewriteFullTextQuery(DbCommand cmd) 在 Fissoft.EntityFramework.Fts.FtsInterceptor.ReaderExecuting(DbCommand command, DbCommandInterceptionContext
1 interceptionContext) 在 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__d(IDbCommandInterceptor i, DbCommand t, DbCommandInterceptionContext
1 c) 在 System.Data.Entity.Infrastructure.Interception.InternalDispatcher1.Dispatch(TTarget target, Func
3 operation, TInterceptionContext interceptionContext, Action3 executing, Action
3 executed) 在 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext) 在 System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior) 在 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) 在 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) --- 内部异常堆栈跟踪的末尾 --- 在 System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) 在 System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute(ObjectContext context, ObjectParameterCollection parameterValues) 在 System.Data.Entity.Core.Objects.ObjectQuery1.<>c__DisplayClass7.<GetResults>b__6() 在 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func
1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) 在 System.Data.Entity.Core.Objects.ObjectQuery1.<>c__DisplayClass7.<GetResults>b__5() 在 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func
1 operation) 在 System.Data.Entity.Core.Objects.ObjectQuery1.GetResults(Nullable
1 forMergeOption) 在 System.Data.Entity.Core.Objects.ObjectQuery1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() 在 System.Data.Entity.Internal.LazyEnumerator
1.MoveNext() 在 System.Collections.Generic.List1..ctor(IEnumerable
1 collection) 在 System.Linq.Enumerable.ToList(IEnumerable`1 source) 在 ProductTest.SqlServerFullTextTest.FullTextTest() 位置 SqlServerFullTextTest.cs: line 28