code_junkie

How do I get the max data size of every column in an IQuerable using LINQ

Nov 11th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. public IEnumerable GetColumnSize(IQueryable source)
  2. {
  3. var types = MapTypeToMembers(source).Select(x => x.Type);
  4. return types.Select(x => MapTypeToSize(x));
  5. }
  6.  
  7. var lengths = from o in myObjectCollection
  8. select new
  9. {
  10. PropertyLength1 = o.Property1.ToString().Length,
  11. PropertyLength2 = o.Property2.ToString().Length,
  12. ...
  13. }
  14.  
  15. var lengths = from o in myObjectCollection
  16. select o.ToString().Length;
Add Comment
Please, Sign In to add comment