This is a migrated thread and some comments may be shown as answers.

Why not IEnumerable as Datasource on ObjectDataSource?

2 Answers 224 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sverre
Top achievements
Rank 2
Sverre asked on 05 Nov 2010, 11:36 PM
Why can't I connect an object that implements IEnumerable as a DataSource on an ObjectDataSource? The following class is allowed:
public class MyClass
{
    private int test;
 
    public int Test
    {
      get { return test; }
      set { test = value; }
    }
 
    public IEnumerator GetEnumerator()
    {
        return null;
    }
}

but if I add ": IEnumerable" after "MyClass", the Data Explorer on the report only displays the message "No Data Source"

I'm using Telerik Reporting 2010 Q2 SP1 (4.1.10.921)

BTW: My real class returns an enumerator from GetEnumerator(), that is not the problem...

Sverre

    public class MyClass
{
        private int test;

        public int Test
        {
          get { return test; }
          set { test = value; }
        }

        public IEnumerator GetEnumerator()
        {
            return null; 
        }
   

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 10 Nov 2010, 08:22 PM
Hello Sverre,

So far the described behavior is by design. When you mark the class with IEnumerable, the ObjectDataSource would pick that up, however it returns null so it shows empty Data Explorer.

Please send us your actual class, so we can investigate whether there is indeed a problem with our logic or the problem is with your enumerator.

Sincerely yours,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sverre
Top achievements
Rank 2
answered on 10 Nov 2010, 09:54 PM
I have finally been able to find out what I've been doing wrong: I've been implementing the non-generic version of IEnumerable on my class to return an IEnumerator from a generic list. When I altered my code to implement IEnumerable<T>, the ObjectDataSource returns data.

Thank you for your help...

Sverre.
Tags
General Discussions
Asked by
Sverre
Top achievements
Rank 2
Answers by
Steve
Telerik team
Sverre
Top achievements
Rank 2
Share this question
or