Skip to main content

How would one convert this linq/lambda expression to .net cobol

return Enumerable.Range(0, reader.FieldCount)
                 .ToDictionary(
                     i => reader.GetName(i),
                     i => reader.GetValue(i));
What I have so far is invoke type Enumerable::Range(0, reader::FieldCount)::ToDictionary(
I do not know how to covert the lambda expressions to .net cobol or is it possible?.

How would one convert this linq/lambda expression to .net cobol

return Enumerable.Range(0, reader.FieldCount)
                 .ToDictionary(
                     i => reader.GetName(i),
                     i => reader.GetValue(i));
What I have so far is invoke type Enumerable::Range(0, reader::FieldCount)::ToDictionary(
I do not know how to covert the lambda expressions to .net cobol or is it possible?.
It should be possible to use anonymous methods in place of the lambda expressions (which are really just an alternative, more streamlined way of expressing C# anonymous methods). Something like:

set return-value to type Enumerable::Range(0, reader::FieldCount)::ToDictionary
(
delegate (i as binary-long) returning ret as string
set ret to reader::GetName(i)
end-delegate
delegate (i as binary-long) returning ret as binary-long (?)
set ret to reader::GetValue(i)
end-delegate
)

How would one convert this linq/lambda expression to .net cobol

return Enumerable.Range(0, reader.FieldCount)
                 .ToDictionary(
                     i => reader.GetName(i),
                     i => reader.GetValue(i));
What I have so far is invoke type Enumerable::Range(0, reader::FieldCount)::ToDictionary(
I do not know how to covert the lambda expressions to .net cobol or is it possible?.
Cobol was not happy with the syntax of the delegate. Here is the complete code that I am attempting to use it with.

method-id btnOK_Click (sender as object e as type System.EventArgs) final private.
local-storage section.
01 dict type Dictionary[string, string] value new Type Dictionary[string, string].
01 ret string.
01 i binary-long.

perform using conn as type MySqlConnection = new MySqlConnection(type Connection::GetConnection)
invoke conn::Open()
perform using cmd as type MySqlCommand = new MySqlCommand("GetUser", conn)
set cmd::CommandType to type CommandType::StoredProcedure
invoke cmd::Parameters::AddWithValue("@username", tbUserName::Text)
invoke cmd::Parameters::AddWithValue("@password", tbPassword::Text)
perform using rdr as type MySqlDataReader = cmd::ExecuteReaderExtended
perform until not rdr::Read()
set dict to type Enumerable::Range(0, rdr::FieldCount)::ToDictionary
(
delegate i returning ret as string
set ret to rdr::GetName(i)
end-delegate

delegate i returning ret as binary-long
set ret to rdr::GetValue(i)
end-delegate
)
end-perform
end-perform
end-perform
end method.

How would one convert this linq/lambda expression to .net cobol

return Enumerable.Range(0, reader.FieldCount)
                 .ToDictionary(
                     i => reader.GetName(i),
                     i => reader.GetValue(i));
What I have so far is invoke type Enumerable::Range(0, reader::FieldCount)::ToDictionary(
I do not know how to covert the lambda expressions to .net cobol or is it possible?.
You don't have parenthesis around the arguments to the delegates:

delegate (I) returning ret as string
set ret to rdr::GetName(i)
end-delegate

How would one convert this linq/lambda expression to .net cobol

return Enumerable.Range(0, reader.FieldCount)
                 .ToDictionary(
                     i => reader.GetName(i),
                     i => reader.GetValue(i));
What I have so far is invoke type Enumerable::Range(0, reader::FieldCount)::ToDictionary(
I do not know how to covert the lambda expressions to .net cobol or is it possible?.
when I use delegate (I) returning ret... I am getting unrecognized verb at (I) and also and error at ToDictionary saying it has no visible to which generic parameter types can be inferred.

How would one convert this linq/lambda expression to .net cobol

return Enumerable.Range(0, reader.FieldCount)
                 .ToDictionary(
                     i => reader.GetName(i),
                     i => reader.GetValue(i));
What I have so far is invoke type Enumerable::Range(0, reader::FieldCount)::ToDictionary(
I do not know how to covert the lambda expressions to .net cobol or is it possible?.
The params used in an anonymous delegate need to specified as new parameters using AS, etc. You are passing an existing data item in working-storage.
The following works for me:
delegate(ind as binary-long) returning delret as string
set ret to rdr::GetName(ind)
end-delegate
delegate(ind2 as binary-long) returning delret2 as binary-long
set ret to rdr::GetValue(ind2)
end-delegate

How would one convert this linq/lambda expression to .net cobol

return Enumerable.Range(0, reader.FieldCount)
                 .ToDictionary(
                     i => reader.GetName(i),
                     i => reader.GetValue(i));
What I have so far is invoke type Enumerable::Range(0, reader::FieldCount)::ToDictionary(
I do not know how to covert the lambda expressions to .net cobol or is it possible?.
declare something = type Enumerable::Range(0, rdr::FieldCount)::ToDictionary
(
delegate using i as binary-long returning ret as string set ret to rdr::GetName(i) end-delegate
delegate using i as binary-long returning ret as string set ret to rdr::GetValue(i) end-delegate
)

I figured it out .

How would one convert this linq/lambda expression to .net cobol

return Enumerable.Range(0, reader.FieldCount)
                 .ToDictionary(
                     i => reader.GetName(i),
                     i => reader.GetValue(i));
What I have so far is invoke type Enumerable::Range(0, reader::FieldCount)::ToDictionary(
I do not know how to covert the lambda expressions to .net cobol or is it possible?.
set dict to type Enumerable::Range(0, rdr::FieldCount)::ToDictionary
(
delegate using i as binary-long returning ret as string set ret to rdr::GetName(i) end-delegate
delegate using i2 as binary-long returning ret2 as string set ret2 to rdr::GetValue(i2) end-delegate
)