代码之家  ›  专栏  ›  技术社区  ›  No Body

亚音速3.0.0.3简单定位[亚音速忽略]

  •  1
  • No Body  · 技术社区  · 17 年前

    我上了一节[亚音速]课:

    [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
    

    我注意到它只会破坏那些有[亚音速忽略]的属性。这是错误还是设计的?

    我使用了C:\ Program Files\Microsoft Visual Studio 9.0\Samples\1033\csharpSamples\LinqSamples\dynamicquery中的类。

    1 回复  |  直到 17 年前
        1
  •  1
  •   Adam Cooper    17 年前

    你试图让亚音速的顺序列,你也明确告诉它忽略。这是按设计的,因为亚音速没有名称成员的概念(您使用subsonic ignore告诉它忽略此属性),所以您不能在亚音速查询中按顺序、按选择或使用该属性。 查看您的代码,您可能会执行以下操作:

    [Test]
    public void Can_Sort()
    {
      IUserRepository _repo = new SqlUserRepository();
      var users = _repo.GetUsers().OrderBy("FirstNAme");