ITPub博客

首页 > 数据库 > > RavenDb使用

RavenDb使用

作者:gaokeke123 时间:2022-04-14 11:14:01 0 删除 编辑
在Raven中查询数据,查询条件必须在index中。

如果查询条件不在index中就会出现如下异常

  1. var query = session.DynamicIndexQuery<ServiceProviderCallTransaction>()
  2. .Where(x => x.LocationId == request.Id).ToList()

System.ArgumentException: The field 'LocationId' is not indexed, cannot query on fields that are not indexed

在Raven中创建Index

public class App_ActivityLog : AbstractIndexCreationTask<ActivityLog>
    {
        public App_ActivityLog()
        {
            Map = records => from record in records
                             select new
                             {
                                 Id = record.Id,
                                 ClientId = record.ClientId,
                                 ActivityDate = record.ActivityDate,
                                 CategoryId = record.CategoryId,
                                 NameId = record.NameId,
                                 StaffId = record.StaffId,
                                 Status_Value = record.Status.Value,
                                 LocationId = record.LocationId,
                                 ProcedureCode = record.ProcedureCode,
                                 Affiliation_Value = record.Affiliation.Value,
                                 SourceReferenceId = record.SourceReferenceId,
                                 ClaimId = record.ClaimId,
                                 ProgramTypeId = record.ProgramTypeId
                             };
        }
    }

转载于:https://www.cnblogs.com/13579net/p/3484059.html

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26692020/viewspace-3161219/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
大家好

注册时间:2013-08-14

  • 博文量
    1432
  • 访问量
    31655