tags:

views:

152

answers:

1

I got a class with [SubSonicIgnore]:

[SubSonicIgnore]
        public string Name
        {
            get
            {
                return (FirstName ?? string.Empty) + ((MiddleName ?? string.Empty).Length > 0 ? " " + MiddleName + " " : " ") + (SurName ?? string.Empty);
            }
        }

whenver I run my test:

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

It always yield an error:

TestQueryableSorter.Can_Sort : FailedSystem.NotSupportedException: The member 'Name' is not supported

I notice that it only breaks on those properties which has [SubSonicIgnore]. Is this a bug or by design?

I used the class from C:\Program Files\Microsoft Visual Studio 9.0\Samples\1033\CSharpSamples\LinqSamples\DynamicQuery.

+1  A: 

You are trying to get SubSonic to order by a column that you are also explicitly telling it to ignore. This is by design, since SubSonic has no concept of the Name member (you are telling it to ignore this property using SubSonicIgnore) you cannot order by, select by or use that property in your SubSonic queries. Looking at your code you could probably do the following instead:

[Test]
public void Can_Sort()
{
  IUserRepository _repo = new SqlUserRepository();
  var users = _repo.GetUsers().OrderBy("FirstNAme");
Adam
How can I tell SubSonic only to ignore if I am pushing the data to the database/table?
No Body
You can't, in your example you have what is basically a computed column, SubSonic can't turn this into a SQL query it won't know how. I've added an example of how you could sort to my answer.
Adam