Skip to main content

I am using Visual Cobol latest version 4.7.03056 on Visual Studio 2017.  I have nearly converted most of my linq expressions to delegates and/or method groups with success.  However, I am puzzled on how to convert this simple select statement.

var query  = ingredients.Select(x => new { Name = x.Name, Length = x.Name.Length}

My take on this is not right of course, because I don't know how to do the return and setup the new {} without using a named class.

 

declare query = ingredients::Select(delegate(x as type Ingredients) returning ret as table of string occurs any

          new table of ret(Name = x::Name)

          new table of ret(Length = x::Length)

end-delegate)

 

I am using Visual Cobol latest version 4.7.03056 on Visual Studio 2017.  I have nearly converted most of my linq expressions to delegates and/or method groups with success.  However, I am puzzled on how to convert this simple select statement.

var query  = ingredients.Select(x => new { Name = x.Name, Length = x.Name.Length}

My take on this is not right of course, because I don't know how to do the return and setup the new {} without using a named class.

 

declare query = ingredients::Select(delegate(x as type Ingredients) returning ret as table of string occurs any

          new table of ret(Name = x::Name)

          new table of ret(Length = x::Length)

end-delegate)

 

Unfortunately there is no support for anonymous types in Visual COBOL. The only alternative I can think of is to define a class, use a System.Tuple or use an array of objects.