不支持表达式类型:System.Linq.Expressions.TypedParameterExpression



我正在做一个项目。我有以下型号的

public class RegistrantClass : IRavenEntity
{
   public RegistrantClass()
   {
       RegistrantId = new List<string>();
   }
   public int Id { get; set; }
   public IList<String> RegistrantId { get; set; }
   public String ClassId { get; set; }
}

我有以下定义的索引

        store.DatabaseCommands.PutIndex("RegistrantClass/ClassByStudents",
                            new IndexDefinitionBuilder<RegistrantClass>
                            {
                                Map = students => from i in students
                                                  from j in i.RegistrantId
                                                  select new { j }
                            });

我试着像一样查询上面的索引

public object GetMapping(string registrantId)
{
 var mapping = _session.Query<RegistrantClass>("RegistrantClass/ClassByStudents")
                             .Customize(i => i.Include<RegistrantClass>(k => k.RegistrantId))
                             .Customize(i => i.Include<RegistrantClass>(k => k.ClassId))
                             .FirstOrDefault(m => m.registrantId.Contains(registrantId));
return mapping;
}

但后来我收到错误消息

然而,这给了我NotSupportedException:不支持的方法:Contains。

我尝试使用以下代码

 .FirstOrDefault(m => registrantId.In<string>(m.RegistrantId));

但随后我收到以下错误消息

Expression type not supported: System.Linq.Expressions.TypedParameterExpression

我做错了什么。亲切问候

你需要用另一种方法:

不是:

.FirstOrDefault(m => registrantId.Contains(m.RegistrantId));

但是:

.FirstOrDefault(m => m.RegistrantId.In(registrantId));

相关内容

最新更新