Code Monkey home page Code Monkey logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on September 7, 2024
I'm guessing you're talking about MoreEnumerable.ToDataTable methods. If so, I 
think this will overload the functionality unnecessarily when the desired 
effect can be achieved already by projecting the dynamic object to an anonymous 
one, with strong-typed and bound members, before calling ToDataTable. For 
example:

dynamic pt1 = new ExpandoObject();
pt1.X = 123;
pt1.Y = 456;
dynamic pt2 = new ExpandoObject();
pt2.X = 456;
pt2.Y = 789;
var points =
    from pt in new[] { pt1, pt2 }
    select new { X = pt.X * 2, 
                 Y = pt.Y * 3 };
points.ToDataTable();    

Original comment by azizatif on 23 Sep 2014 at 10:02

  • Changed state: WontFix

from morelinq.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 7, 2024
[deleted comment]

from morelinq.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 7, 2024
Hi thanks for responding so fast.

Your answer will only work if at compile time you knew the fields that would 
exist. In the instance I am dealing with I'm generating the object at runtime 
by using a method to merge 2 objects Tuple<T1,T2> into a single dynamic/expando 
object.

Thanks

Original comment by [email protected] on 23 Sep 2014 at 10:32

from morelinq.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 7, 2024
True but if you don't know the properties all you can do at run-time with 
IDynamicMetaObjectProvider at runtime is discover the property names and their 
values, but cannot know the types of the properties in advance. Without the 
types, all columns of such a DataTable would be of type System.Object, which I 
think is odd. Moreover, a sequence of dynamics, or just objects for that 
matter, don't have to be the same type! As a result, the DataTable cannot be 
said to have a uniform schema. MoreEnumerable.ToDataTable like many other 
methods in LINQ are designed to work over a sequence of homogenous objects of 
some type T. If T is dynamic, that's no different than object and a sequence of 
such would have to be assumed to be heterogeneous. Even in LINQ, if you have 
IEnumerable, you have to go over Enumerable.Cast<T> before you can benefit from 
any of the other standard query operators.

Original comment by azizatif on 23 Sep 2014 at 11:09

from morelinq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.