forked from ravendb/ravendb
/
CustomEntityName.cs
50 lines (44 loc) · 1.3 KB
/
CustomEntityName.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//-----------------------------------------------------------------------
// <copyright file="CustomEntityName.cs" company="Hibernating Rhinos LTD">
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Linq;
using Raven.Client.Document;
using Xunit;
namespace Raven.Tests.Bugs
{
public class CustomEntityName : LocalClientTest
{
[Fact]
public void CanCustomizeEntityName()
{
using(var store = NewDocumentStore())
{
store.Conventions.FindTypeTagName = ReflectionUtil.GetFullNameWithoutVersionInformation;
using(var session = store.OpenSession())
{
session.Store(new Foo{Name = "Ayende"});
session.SaveChanges();
}
using (var session = store.OpenSession())
{
var typeName = ReflectionUtil.GetFullNameWithoutVersionInformation(typeof(Foo));
var all = session
.Advanced
.LuceneQuery<Foo>("Raven/DocumentsByEntityName")
.Where("Tag:[[" + typeName + "]]")
.WaitForNonStaleResultsAsOfNow(TimeSpan.MaxValue)
.ToList();
Assert.Equal(1, all.Count);
}
}
}
public class Foo
{
public string Id { get; set; }
public string Name { get; set; }
}
}
}