Created
April 29, 2013 10:32
-
-
Save amarraja/5480858 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StoreTest | |
{ | |
public class Holder | |
{ | |
public string SomeString { get; set; } | |
} | |
public class HolderIndex : AbstractIndexCreationTask<Holder, HolderIndex.ReduceResult> | |
{ | |
public class ReduceResult | |
{ | |
public string SomeString { get; set; } | |
} | |
public HolderIndex() | |
{ | |
Map = holders => from holder in holders | |
select new {holder.SomeString}; | |
} | |
} | |
[Test] | |
public void NoStoreGetsFieldFromIndex() | |
{ | |
var dataDir = "c:\\raventests\\" + DateTime.Now.ToString("yyyy-MM-dd-HHmmss"); | |
if (!Directory.Exists(dataDir)) | |
Directory.CreateDirectory(dataDir); | |
var store = new EmbeddableDocumentStore() { DataDirectory = dataDir }.Initialize(); | |
using (store) | |
{ | |
new HolderIndex().Execute(store); | |
using (var s = store.OpenSession()) | |
{ | |
s.Store(new Holder() { SomeString = "CamelCased"}); | |
s.SaveChanges(); | |
} | |
using (var s = store.OpenSession()) | |
{ | |
var holder = s.Query<HolderIndex.ReduceResult, HolderIndex>() | |
.Customize(c => c.WaitForNonStaleResults()) | |
.AsProjection<HolderIndex.ReduceResult>() | |
.Where(n => n.SomeString == "camelcased") | |
.First(); | |
//This prints "CamelCased", when I would expect it to be "camelcased" | |
//as I have not indicated the field is stored | |
Trace.WriteLine(holder.SomeString); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment