Created
February 1, 2013 16:25
-
-
Save mattjohnsonpint/4692351 to your computer and use it in GitHub Desktop.
Example for SO Q14644619
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
using System.Diagnostics; | |
using System.Linq; | |
using Raven.Tests.Helpers; | |
using Xunit; | |
namespace RavenTests.StackOverflow | |
{ | |
public class Q14644619 : RavenTestBase | |
{ | |
public class UserAccountInfo | |
{ | |
public string Id { get; set; } | |
public object User { get; set; } | |
} | |
public class AccountInfoCustomer | |
{ | |
public CustomerStatus CustomerStatus { get; set; } | |
} | |
public enum CustomerStatus | |
{ | |
Pending, | |
New, | |
Old, | |
Dead | |
} | |
[Fact] | |
public void Test() | |
{ | |
using (var documentStore = NewDocumentStore()) | |
{ | |
using (var session = documentStore.OpenSession()) | |
{ | |
session.Store(new UserAccountInfo { User = new AccountInfoCustomer { CustomerStatus = CustomerStatus.Pending } }); | |
session.Store(new UserAccountInfo { User = new AccountInfoCustomer { CustomerStatus = CustomerStatus.Pending } }); | |
session.Store(new UserAccountInfo { User = new AccountInfoCustomer { CustomerStatus = CustomerStatus.Dead} }); | |
session.SaveChanges(); | |
} | |
using (var session = documentStore.OpenSession()) | |
{ | |
var q = session.Query<UserAccountInfo>() | |
.Customize(x => x.WaitForNonStaleResults()) | |
.Where(x => ((AccountInfoCustomer) x.User).CustomerStatus == CustomerStatus.Pending); | |
Debug.WriteLine(q); | |
var results = q.ToList(); | |
Assert.Equal(2, results.Count); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment