using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using NUnit.Framework;
|
|
using MongoDB.Bson;
|
using MongoDB.Driver;
|
using MongoDB.Driver.Linq;
|
using MongoDB.Bson.Serialization.Attributes;
|
using MongoDB.Driver.Builders;
|
|
namespace MongoDB.DriverUnitTests.Jira.CSharp537
|
{
|
[TestFixture]
|
public class CSharp537Tests
|
{
|
enum UserType
|
{
|
Admin,
|
General,
|
Affiliate
|
}
|
|
class User
|
{
|
public ObjectId Id { get; set; }
|
public UserType Type { get; set; }
|
}
|
|
[Test]
|
public void TestTypedBuildersWithSubclasses()
|
{
|
var db = Configuration.TestDatabase;
|
var collection = db.GetCollection<User>("csharp537");
|
collection.Drop();
|
|
collection.Save(new User { Type = UserType.Admin });
|
collection.Save(new User { Type = UserType.Affiliate });
|
collection.Save(new User { Type = UserType.Affiliate });
|
|
var result = from user in collection.AsQueryable()
|
where user.Type == UserType.Affiliate
|
select user;
|
|
var count = result.Count();
|
|
Assert.AreEqual(2, count);
|
}
|
}
|
}
|