0
我想创建一个简单的索引,其中包括我的文档中的两个字段:TraceRowID,LoadDate。不能通过C#添加索引到RavenDB数据库
所以我创建了以下类:
using Model;
using Raven.Abstractions.Indexing;
using Raven.Client.Indexes;
using Raven.Client.Linq;
using Raven.Client.Document;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Indexes
{
public class IDLoadDateIndex : AbstractIndexCreationTask<ServiceTrace>
{
public IDLoadDateIndex()
{
Map = serviceTrace => from st in serviceTrace
select new { ID = st.TraceRowID, LoadDate = st.LoadDate };
}
}
}
我的模式是 “ServiceTrace”:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class ServiceTrace
{
public int TraceRowID { get; set; }
public string StatusDescription { get; set; }
public string FullExceptionText { get; set; }
public string LoadDate { get; set; }
}
}
那还有我的DAL:
using Indexes;
using Raven.Client.Indexes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DAL
{
public class DbConnection
{
private readonly static DbConnection instance = new DbConnection();
private Raven.Client.Document.DocumentStore documentStore;
static DbConnection()
{
}
private DbConnection()
{
this.documentStore = new Raven.Client.Document.DocumentStore { Url = "http://btadmins:8080/" };
this.documentStore.Initialize();
IndexCreation.CreateIndexes(typeof(IDLoadDateIndex).Assembly, this.documentStore);
}
public static DbConnection Instance
{
get
{
return instance;
}
}
public Raven.Client.Document.DocumentStore DocumentStore
{
get
{
return documentStore;
}
}
}
}
出于某种原因,当在“CreateIndexes”行上逐步调试模式时,它会成功完成。但我看不到在RavenDB管理工作室Silverlight应用程序中添加的任何索引。 有什么问题?
我按顶部栏菜单上的“索引”,并且只有默认值:“Raven/DocumentsByEntityName”索引 – ohadinho 2013-05-02 15:20:44
@ohadinho而在右上角,你看到'数据库>'或某事其他?请参阅[文档](http://ravendb.net/docs/2.0/studio/multi-database) –
2013-05-02 22:32:02
我看到数据库> –
ohadinho
2013-05-03 21:55:48