0
votes

i Have Kendo ui Grid In My Project (client side) and in my grid FilterAble and Sortable and ... is true and set on serverSide operation

but my database is mongodb and now when in my client user set filter i got this error

An exception of type 'System.InvalidOperationException' occurred in MongoDB.Driver.dll but was not handled in user code Additional information: Compare({document}{Name}.ToLower(), "test") is not supported.

because i use webapi i Create My own DataSourceRequest Class without inheritance when i want convert my own class to DataSourceRequest with this method(for filterAble )

 if (model.Filter != null && model.Filter.Filters.Count > 0)
        {
            var filters = new FilterDescriptorCollection();

            foreach (var f in model.Filter.Filters)
            {
                FilterDescriptor filter = new FilterDescriptor()
                {
                    Member = f.Field,
                    Operator =(FilterOperator)f.Operator,
                    Value = f.Value
                };
                filters.Add(filter);
            }

            request.Filters = filters;
        }

this my repository

 var result = _context.Additives.AsQueryable().Select(a => new AdditiveList()
        {
            Id = a.Id.DbId,
            Name = a.Name,
            CurrentWeight = a.CurrentWeight,
            InitialWeight = a.InitialWeight
        }).ToDataSourceResult(model.ToDataSourceRequest());

now i have this question i was wrong for filter Creating ? or kendo dont support mongo operation and i must write this for myself?

tnks

1
What do you think about Compare({document}{Name}.ToLower(), "test")? May you put that block of code in your project include this part (Compare({document}{Name}.ToLower(), "test") in your question? - RAM
this block created by kendo ui (ToDataSourceResult) I Add Repository Code - Soheil Karami
Have you any name with NULL value in the Additives? Try fill all of the name field values with some data else null and test again. Do you see the error after apply these changes? - RAM
I dont Have any Null Value for name - Soheil Karami

1 Answers

0
votes

I find my problem in my Filter class (model) i have one enum and my enum has wrong value i change my enum to this values

 public enum MyFilterOperator
{
    Lt,
    Lte,
    Eq,
    Neq,
    Gte,
    Gt,
    Startswith,
    Endswith,
    Contains,
    IsContainedIn,
    Notsubstringof,
    IsNull,
    IsNotNull,
    IsEmpty,
    IsNotEmpty
}

and now every things work correctly