[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VB.net error after conversion from C#

Posted on 2014-01-24
9
Medium Priority
?
380 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:Murray Brown
[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 14

Accepted Solution

by:
Alexander Eßer [Alex140181] earned 1000 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 14

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
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!

 
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 14

Expert Comment

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

Assisted Solution

by:Fernando Soto
Fernando Soto earned 1000 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 14

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 64

Expert Comment

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

Author Closing Comment

by:Murray Brown
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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 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