?
Solved

VB.net error after conversion from C#

Posted on 2014-01-24
9
Medium Priority
?
375 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 13

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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 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 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:Murray Brown
ID: 39811436
Thanks for the help
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

801 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