未为类型定义二元运算符NotEqual

时间:2018-01-17 15:27:25

标签: asp.net-core-2.0

我正在尝试过滤一些这样的元素:

model = model.Where(feature => item
            .Input
            .Contains(feature
                   .GetType()
                   .GetProperty(item.Attribute)
                   .GetValue(feature)
                   .ToString()));

item是一个接收有关过滤数据的对象,例如item.InputList<string>,其中包含用户填写的内容和item.Attributestring })是我应该看的列。我测试错误的字段是Guid?类型的字段,它被称为AssignedUserId,奇怪的是它有效:

model = model.Where(feature => item.Input.Contains(feature.AssignedUserId.ToString()));

作为一个说明,这有效:

model = model.Where(feature => feature
     .GetType()
     .GetProperty(item.Attribute)
     .GetValue(feature)
     .ToString() == item.Input.ElementAt(0));

因此item.Attribute填充良好,过滤器正常工作。

我得到的错误是:

System.InvalidOperationException: The binary operator NotEqual is not defined for the types 'Microsoft.EntityFrameworkCore.Storage.ValueBuffer' and 'Microsoft.EntityFrameworkCore.Storage.ValueBuffer'.

获取第一个代码示例中的字段值有什么问题?

1 个答案:

答案 0 :(得分:2)

您正在使用哪个版本的实体框架?

我遇到了同样的错误,这已在 2.1.0-preview1 版本中修复,如此处所述issue 9771

相关问题