Solved

VB.net error after conversion from C#

Posted on 2014-01-24
9
371 Views
Last Modified: 2014-01-27
Hi. I converted the C# code at the bottom to get the VB.net code below but the system
is showing a few errors. For instance in the row market ERROR I get the message
')' expected

    Public Function PivotData(RowField As String, DataField As String, Aggregate As AggregateFunction, ParamArray ColumnFields As String()) As DataTable
        Dim dt As New DataTable()
        Dim Separator As String = "."
      Dim RowList = (From x In _SourceTable.AsEnumerable()New With { _  'ERROR
            Key .Name = x.Field(Of Object)(RowField) _
      }).Distinct()



public DataTable PivotData(string RowField, string DataField,
       AggregateFunction Aggregate, params string[] ColumnFields)
{
    DataTable dt = new DataTable();
    string Separator = ".";
    var RowList = (from x in _SourceTable.AsEnumerable()
        select new { Name = x.Field<object>(RowField) }).Distinct();
    var ColList = (from x in _SourceTable.AsEnumerable()
                   select new { Name = ColumnFields.Select(n => x.Field<object>(n))
                       .Aggregate((a, b) => a += Separator + b.ToString()) })
                       .Distinct()
                       .OrderBy(m => m.Name);
0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 13

Accepted Solution

by:
Alexander Eßer [Alex140181] earned 250 total points
ID: 39806034
Have you tried this (untested)?!
	 Public Function PivotData(RowField As String, DataField As String, Aggregate As AggregateFunction, ParamArray ColumnFields As String()) As DataTable
        Dim dt As New DataTable()
        Dim Separator As String = "."
      Dim RowList = (From x In _SourceTable.AsEnumerable() Select New With { Key .Name = x.Field(Of Object)(RowField)  }).Distinct()

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39806040
Aggregate As AggregateFunction  must be AggregateFunction As Aggregate
0
 
LVL 13

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39806090
Aggregate As AggregateFunction  must be AggregateFunction As Aggregate
I doubt it, it has to be from Microsoft Dynamics AX... (http://msdn.microsoft.com/en-us/library/microsoft.dynamics.ax.framework.workflow.model.axqueryservicereference.aggregatefunction.aspx)
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39806102
sorry, but there AggregateFunction you refer to is is a Enum, and looking at the code I doubt that would do it, as it tries to "use" the "function" indeed.

anyhow, reading another question from the asker, this code was converted from C# to vb.net, and the conversion did not work correctly, and the Aggregate is simply a LINQ "type"
0
 
LVL 13

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39806106
Sorry, I was just too quick on that to respond :-( My bad...
0
 
LVL 63

Assisted Solution

by:Fernando Soto
Fernando Soto earned 250 total points
ID: 39806847
Hi Alexander Eßer;

See if this code snippet get you any closer.

Public Function PivotData(RowField As String, DataField As String, 
        Aggregate As AggregateFunction, ParamArray ColumnFields As String()) As DataTable
        
    Dim dt As New DataTable()
    Dim Separator As String = "."
    Dim RowList = (From x In _SourceTable.AsEnumerable() _
                   Select New With _
                   { _
                       .Name = x.Field(Of Object)(RowField) _
                   }).Distinct()
                   
    var ColList = (From x in _SourceTable.AsEnumerable() _
                   Select New With _
                   { _
                   	   .Name = ColumnFields.Select(Function(n) x.Field(Of Object)(n)) _
                                           .Aggregate(Function(a, b) a &= Separator & b.ToString()) _
                   }).Distinct() _
                     .OrderBy(Function(m) m.Name)
                   
End Function  

Open in new window

0
 
LVL 13

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39807961
That's too kind,  Fernando, but it's not me who's asking ;-)
Thanks anyways...
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39807996
Sorry, that should have been murbro.
0
 

Author Closing Comment

by:murbro
ID: 39811436
Thanks for the help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question