Here's a suggestion:
string questiontitle = "abc def ghi jkl mno";
string questiontext = "ab cd ef gh ij kl mn op";
string filter = "kl ghi";
int found_count = 0;
string[] split_filter = filter.Split(" ");
for (int idx = 0; idx < split_filter.Length; idx++)
{
if (questiontext.Contains(split_filter[idx])
|| questiontitle.Contains(split_filter[idx]))
{
found_count++;
continue;
}
else
{
break;
}
}
if (found_count == split_filter.Length)
{
// all filter terms found
}
else
{
// all filter terms NOT found
}
The code has not been tested. It's offered to convey a concept. In this example the filter terms are found across Text and Title. Another search method might be to search for "all filter terms in Text" || "all filter terms in Title".
i'm not searching for code. I'm searching for discussions and possible solutions. I seem to have mis-identified my search target, which is this support forum/blog or whatever you call this collection of thousands of questions and discussions. I'm referring the the search control on the main page. How can I search this forum for the existence of words anywhere in the discussions, instead only for an exact match phrase?
When searching the repository for "customize" 53 results are returned. When searching for "theme" 165 results are returned. When searching for "customize theme" 1 result is returned: this one. When searching for the above 2 words in reverse order, 0 results are returned. How can I search the respository for the existence of words, instead only for an exact match phrase?
That did the trick. A very big THANK YOU!
I have a routine that processes files of data to be parsed and written to my db. I'm using IUnitOfWorkManager:
IUnitOfWorkManager unitOfWorkManager;
... initialization ...
try
{
using (var unitOfWork = unitOfWorkManager.Begin())
{
do
{
... process an input file record ...
if (error_1)
{
status.success = false;
status.FailureReason = "some reason";
return status;
}
else if (error_2)
{
status.success = false;
status.FailureReason = "some other reason";
throw new Exception("MyException");
}
else
{
... get next record from input file ...
}
} until EOF;
unitOfWork.Complete();
status.success = true;
return status;
}
}
catch (Exception ex)
{
if (ex.Message == "MyException")
{
return status;
}
status.Success = false;
status.FailureReason = ex.Message;
return failure_code_obj;
}
When a failure occurs, I want to abandon the transaction and roll back all records written within the UoW.
However, when a failure occurs, instead of rolling back the transaction (by virtue of not calling UoW.Complete() ), the records are written to the db,
and the Exception message is "Did not call Complete method of a unit of work."
I tried calling UoW.Dispose()
, tried throw new Exception("MyException")
if error - to no avail. The transaction is not rolled back and my db records are out of sync.
I do not want the system default Exception handler to pop up it's message in the browser; I have a custom error modal dialog (the return status;
has many fields describing the cause of the error and remedy for the user to fix the problem).
How can I direct UoW to abandon and roll back the current transaction, and return my custom error status?
I solved the issue by upgrading all my migrated code to .NetCore.
Warning CS1998 This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base\UiCustomization\NullUiThemeCustomizerFactory.cs UserApp.Test.Base C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base\UiCustomization 8 Active
Warning CS0693 Type parameter 'T' has the same name as the type parameter from outer type 'AppTestBase<T>' C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base\AppTestBase.cs UserApp.Test.Base C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base 72 Active
Warning CS0693 Type parameter 'T' has the same name as the type parameter from outer type 'AppTestBase<T>' C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base\AppTestBase.cs UserApp.Test.Base C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base 77 Active
Warning CS0693 Type parameter 'T' has the same name as the type parameter from outer type 'AppTestBase<T>' C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base\AppTestBase.cs UserApp.Test.Base C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base 106 Active
Warning CS0693 Type parameter 'T' has the same name as the type parameter from outer type 'AppTestBase<T>' C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base\AppTestBase.cs UserApp.Test.Base C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base 122 Active
Warning CS1998 This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base\UiCustomization\NullThemeUiCustomizer.cs UserApp.Test.Base C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.Test.Base\UiCustomization 11 Active
Warning CS4014 Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call. C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\src\UserApp.Core\MultiTenancy\SubscriptionExpirationCheckWorker.cs UserApp.Core C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\src\UserApp.Core\MultiTenancy 77 Active
Warning CS4014 Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call. C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\src\UserApp.Core\MultiTenancy\SubscriptionExpirationCheckWorker.cs UserApp.Core C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\src\UserApp.Core\MultiTenancy 97 Active
Warning CS4014 Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call. C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\src\UserApp.Core\MultiTenancy\SubscriptionExpireEmailNotifierWorker.cs UserApp.Core C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\src\UserApp.Core\MultiTenancy 52 Active
Warning CS0618 'DiscoveryClient' is obsolete: 'This type will be deprecated or changed in a future version. It is recommended that you switch to the new extension methods for HttpClient. They give you much more control over the HttpClient lifetime and configuration. See the docs here: https://identitymodel.readthedocs.io' C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.ConsoleApiClient\Program.cs UserApp.ConsoleApiClient C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.ConsoleApiClient 41 Active
Warning CS0618 'TokenClient' is obsolete: 'This type will be deprecated or changed in a future version. It is recommended that you switch to the new extension methods for HttpClient. They give you much more control over the HttpClient lifetime and configuration. See the docs here: https://identitymodel.readthedocs.io' C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.ConsoleApiClient\Program.cs UserApp.ConsoleApiClient C:\AspNetZero\UserApp 6.8.0 Core 2.2\UserApp\aspnet-core\test\UserApp.ConsoleApiClient 47 Active