我的课程有[SubSonicIgnore]:
[SubSonicIgnore]
public string Name
{
get
{
return (FirstName ?? string.Empty) + ((MiddleName ?? string.Empty).Length > 0 ? " " + MiddleName + " " : " ") + (SurName ?? string.Empty);
}
}
当我运行我的测试时:
[Test]
public void Can_Sort()
{
IUserRepository _repo = new SqlUserRepository();
var users = _repo.GetUsers().OrderBy("Name");
总是会产生错误:
TestQueryableSorter.Can_Sort : FailedSystem.NotSupportedException: The member 'Name' is not supported
我注意到它只会破坏那些具有[SubSonicIgnore]的属性。这是一个错误还是设计?
我使用了C:\ Program Files \ Microsoft Visual Studio 9.0 \ Samples \ 1033 \ CSharpSamples \ LinqSamples \ DynamicQuery中的类。
答案 0 :(得分:1)
您正试图让SubSonic按照您明确告知其忽略的列进行排序。这是设计的,因为SubSonic没有Name成员的概念(你告诉它使用SubSonicIgnore忽略这个属性)你不能在SubSonic查询中排序,选择或使用该属性。 查看代码,您可以执行以下操作:
[Test]
public void Can_Sort()
{
IUserRepository _repo = new SqlUserRepository();
var users = _repo.GetUsers().OrderBy("FirstNAme");