Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T[] Binding for Table query binding #972

Open
mathewc opened this issue Jan 13, 2017 · 3 comments
Open

T[] Binding for Table query binding #972

mathewc opened this issue Jan 13, 2017 · 3 comments
Assignees
Milestone

Comments

@mathewc
Copy link
Member

mathewc commented Jan 13, 2017

Today you can bind TableAttribute to a JArray. Acting as a user, I assumed that also meant that I could bind to T[] (array of pocos). This doesn't work currently.

As part of the Table binding overhaul, I think we should enable this as well? For Table binding usages pulling in a collection JArray, T[], etc. are natural.

@mathewc mathewc added this to the 2.0.0-release milestone Jan 13, 2017
@MikeStall
Copy link
Contributor

We should solve this with some rule in the converter manager that's not Table specific.
Maybe a JArray -> T[] rule?

@MikeStall
Copy link
Contributor

Although a counter-point to consider: If we read T[], then the underlying table call can do a select to only pull down properties on T. Whereas if we read a JArray , then we need to pull down everything first (even unused properties).

@MikeStall
Copy link
Contributor

We could solve this with a JArray --> T[] rule. This approach also lets T be a poco (and not need to derive from ITableEntity). Table could override specifically to optimize with a projection of just T's properties.

Perhaps ConverterManager should special case JArray-->T[]?

converterManager.AddConverter<JArray, OpenType[], TableAttribute>(typeof(JArrayToArrayConverter<>));

        private class JArrayToArrayConverter<T> : IConverter<JArray, T[]>
        {
            public T[] Convert(JArray input)
            {
                if (input == null)
                {
                    throw new ArgumentNullException("input");
                }
                return input.ToObject<T[]>();
            }
        }

@christopheranderson christopheranderson modified the milestones: 2.0.0-release, Next Feb 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants