var store = new DocumentStore { Conventions = { FindIdentityProperty = q => q.Name == "id" } };
public class Task
{
public string id { get; set; } public string Name { get; set; }}
public class Task_Index : AbstractIndexCreationTask<Task, Task_Index.TaskIndexData> { public class TaskIndexData {
public string TaskId { get; set; } public string Name { get; set; } }
public Task_Index() { Map = Tasks => from t in Tasks select new TaskIndexData { TaskId = t.id, Name = t.Name, }; } }
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[TestClass] public class UnitTest3 { [TestMethod] public void TestMethod1() { IDocumentStore store = new DocumentStore { Url = "http://localhost:8080",
Conventions = { FindIdentityProperty = q => q.Name == "id" } };
store.Initialize(); string dbName = "SampleData"; store.DatabaseCommands.EnsureDatabaseExists(dbName);
SampleData_Index ind = new SampleData_Index(); store.DatabaseCommands.ForDatabase(dbName).DeleteIndex(ind.IndexName); store.DatabaseCommands.ForDatabase(dbName).PutIndex(ind.IndexName,ind.CreateIndexDefinition()); using (var session = store.OpenSession(dbName)) { session.Store(new SampleData() { Name = "Raven" }); session.Store(new SampleData() { Name = "Crow" }); session.SaveChanges(); var result = session.Advanced.LuceneQuery<SampleData,SampleData_Index>() .WaitForNonStaleResults() .WhereEquals("Name","Crow") .FirstOrDefault();
Assert.IsNotNull(result);
var result2 = session.Advanced.LuceneQuery<SampleData, SampleData_Index>() .WhereEquals("TaskId", result.id ) .FirstOrDefault();
Assert.IsNotNull(result2); //Fails! } } }
public class SampleData
{ public string id { get; set; } public string Name { get; set; } }
public class SampleData_Index : AbstractIndexCreationTask<SampleData, SampleData_Index.SampleIndexData> { public class SampleIndexData {
public string TaskId { get; set; } public string Name { get; set; } }
public SampleData_Index()
{ Map = Tasks => from t in Tasks
select new SampleIndexData {
docs.SampleDatas.Select(t => new {
TaskId = t.id, Name = t.Name
})
new SampleData_Index();
new SampleData_Index {
Conventions = convention }// deploy index to `Northwind` database // using store `Conventions` new Orders_Totals().Execute(store.DatabaseCommands.ForDatabase("Northwind"), store.Conventions);
--