Commit 690ebde6 authored by VTHIEN's avatar VTHIEN

fixed sieve model RemoveSignVietnameseString

parent 830e1291
using System;
using System.Collections.Generic;
using System.Text;
namespace Sieve.Models
{
public class RemoveVietNamSign
{
private string[] VietnameseSigns = new string[]
{
"aAeEoOuUiIdDyY",
"áàạảãâấầậẩẫăắằặẳẵ",
"ÁÀẠẢÃÂẤẦẬẨẪĂẮẰẶẲẴ",
"éèẹẻẽêếềệểễ",
"ÉÈẸẺẼÊẾỀỆỂỄ",
"óòọỏõôốồộổỗơớờợởỡ",
"ÓÒỌỎÕÔỐỒỘỔỖƠỚỜỢỞỠ",
"úùụủũưứừựửữ",
"ÚÙỤỦŨƯỨỪỰỬỮ",
"íìịỉĩ",
"ÍÌỊỈĨ",
"đ",
"Đ",
"ýỳỵỷỹ",
"ÝỲỴỶỸ"
};
public string RemoveSignAndLowerCase4VietnameseString(string str)
{
for (int i = 1; i < VietnameseSigns.Length; i++)
{
for (int j = 0; j < VietnameseSigns[i].Length; j++)
str = str.Replace(VietnameseSigns[i][j], VietnameseSigns[0][i - 1]);
}
return str;
}
}
}
...@@ -387,6 +387,7 @@ namespace Sieve.Services ...@@ -387,6 +387,7 @@ namespace Sieve.Services
return Expression.Lambda<Func<TEntity, bool>>(outerExpression, parameterExpression); return Expression.Lambda<Func<TEntity, bool>>(outerExpression, parameterExpression);
} }
private IQueryable<TEntity> ApplyFiltering<TEntity>( private IQueryable<TEntity> ApplyFiltering<TEntity>(
TSieveModel model, TSieveModel model,
IQueryable<TEntity> result, IQueryable<TEntity> result,
...@@ -420,6 +421,7 @@ namespace Sieve.Services ...@@ -420,6 +421,7 @@ namespace Sieve.Services
foreach (var filterTermValue in filterTerm.Values) foreach (var filterTermValue in filterTerm.Values)
{ {
//string filterTermValue = this.RemoveSign4VietnameseString(filterTermValue1); //Added by thien to emove vietnam
dynamic constantVal = converter.CanConvertFrom(typeof(string)) dynamic constantVal = converter.CanConvertFrom(typeof(string))
? converter.ConvertFrom(filterTermValue) ? converter.ConvertFrom(filterTermValue)
...@@ -428,11 +430,21 @@ namespace Sieve.Services ...@@ -428,11 +430,21 @@ namespace Sieve.Services
Expression filterValue = GetClosureOverConstant(constantVal, property.PropertyType); Expression filterValue = GetClosureOverConstant(constantVal, property.PropertyType);
if (filterTerm.OperatorIsCaseInsensitive) if (true)//filterTerm.OperatorIsCaseInsensitive Make search insensitive case //comment by thien
{ {
propertyValue = Expression.Call(propertyValue, var upperData = Expression.Call(propertyValue,
typeof(string).GetMethods() typeof(string).GetMethods()
.First(m => m.Name == "ToUpper" && m.GetParameters().Length == 0)); .First(m => m.Name == "ToUpper" && m.GetParameters().Length == 0));
propertyValue = Expression.Call(
Expression.New(typeof(RemoveVietNamSign)),
typeof(RemoveVietNamSign).GetMethod("RemoveSignVietnameseString", new Type[] { typeof(string)}),
upperData
);
/*propertyValue = Expression.Call(propertyValue,
typeof(string).GetMethods()
.First(m => m.Name == "ToUpper" && m.GetParameters().Length == 0));*/
filterValue = Expression.Call(filterValue, filterValue = Expression.Call(filterValue,
typeof(string).GetMethods() typeof(string).GetMethods()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment