Comments (4)
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.
[deleted comment]
from morelinq.
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.
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)
- Usage example for SingleOrFallback HOT 7
- converting IEnumerable<TSource> into IEnumerable<IEnumerable<TSource>>? HOT 2
- Buffering HOT 2
- Please make .NET 4 compatible distribution (or allow silent modifications) HOT 1
- Interleave irregular enumerables with circular strategy HOT 5
- TakeLast example incorrect HOT 5
- Patch for /MoreLinq/DistinctBy.cs HOT 2
- Implement Full Outer Join HOT 1
- Patch for /MoreLinq/EquiZip.cs HOT 1
- Change ArgumentNullException to early return. HOT 1
- MaxByOrDefault HOT 3
- Scan should not throw on empty sequences HOT 1
- Batch should return an IEnumerable<IList<T>> HOT 2
- Migrate to GitHub/BitBucket HOT 15
- add Memoize support HOT 2
- ForEach should optionally take an index HOT 2
- ToDataTable throws on type with public static member HOT 6
- It would be nice to have a Top operator that would merge OrderBy and Take HOT 1
- F# countBy analogue HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from morelinq.