Question
· Jun 10, 2016

Passing a Dictionary (array of data types) from .Net to Caché

I need to pass an equivalent of .Net Dictionary<string, int> instance from .Net to Caché. In the application, the Caché .Net provider has been used so far, so we came up with passing it as an instance of array of data types. However, the only way to fill the array we are aware of is to use its Add() method which invokes a call to the server instance method of the array for every key-value pair inserted.

Is there any way to fill the array at once - inserting all the pairs in one server call? Alternatively, is their any other .Net (Provider or eXTreme) API we can use for this task?

I know that using the Light C++  binding, we could pass the arrays as std::map<d_string, d_int> and a .Net equivalent of this using Dictionary<string, int> would be just perfect..

Discussion (1)1
Log in or sign up to continue

There is the CopyTo() method that will take a System.Array and copy it to the CacheListOfDataTypes. Maybe that helps?

Here is the description:

CopyTo(string[] array, int arrayIndex)

Summary:
Copies the elements of the System.Collections.Generic.ICollection<T> to an System.Array, starting at a particular System.Array index.

Parameters:
array: The one-dimensional System.Array that is the destination of the elements copied from System.Collections.Generic.ICollection<T>. The System.Array must have zero-based indexing.
arrayIndex: The zero-based index in array at which copying begins.