converting c# lambda expression LINQ to vb.net -


i having trouble converting following query vb c#. cant syntax right , ok not great linq. appreciated.

var result = (from d in projectionentities.projections              d.symbolid <= 42              join t in projectionentities.symbols on d.symbolid equals t.id                              group d d.symbolid g              select new {                      symbolid = g.key,                        projectionperformances =                                     g.select(gg=>new projectionperformance{                                                symbolid = gg.symbolid,                                                name = gg.symbol.name,                                                rpdate = gg.date.tostring(),                                                actualrange = gg.highprojection - gg.lowprojection                                               })                   .todictionary(g=>g.symbolid); 

my approach start valid c# , use tool translation. generated result make few adjustments if needed.

this valid c# snippet similar yours, minor alterations.

var projections = new[] {     new { symbolid = 1, name = "", date = datetime.now },      new { symbolid = 2, name = "", date = datetime.now } }; var symbols = new[] { new { id = 1 }, new { id = 2 } };  var result =  (from p in projections             p.symbolid <= 42             join s in symbols on p.symbolid equals s.id             group p p.symbolid g             select new             {                 symbolid = g.key,                 projectionperformances =                             g.select(gg => new                             {                                 symbolid = gg.symbolid,                                 name = gg.name,                                 rpdate = gg.date.tostring(),                             }                                         )             }).todictionary(g => g.symbolid); 

example of website translates c# vb.net - http://www.developerfusion.com/tools/convert/csharp-to-vb

this generated result

dim projections = new () {new { _     key .symbolid = 1, _     key .name = "", _     key .[date] = datetime.now _ }, new { _     key .symbolid = 2, _     key .name = "", _     key .[date] = datetime.now _ }} dim symbols = new () {new { _     key .id = 1 _ }, new { _     key .id = 2 _ }}  dim result = (from g in p in projections  p.symbolid <= 42join s  in symbols on p.symbolid = s.idgroup p p.symbolidnew { _     key .symbolid = g.key, _     key .projectionperformances = g.[select](function(gg) new { _         key .symbolid = gg.symbolid, _         key .name = gg.name, _         key .rpdate = gg.[date].tostring() _     }) _ }).todictionary(function(g) g.symbolid) 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -