When using `dynamic` with Dapper, underlying objects are of type DapperRow,
which is also IDictionary<string, object>,
which is easy to convert to BinaryObject. Here is a full example with
Dapper query:
var dapperQuery = conn.Query("SELECT * FROM Persons");
foreach (IDictionary<string, object> row in dapperQuery)
{
var builder = ignite.GetBinary().GetBuilder("YourEntityNameHere");
foreach (var pair in row)
{
builder.SetField(pair.Key, pair.Value);
}
var binaryObject = builder.Build();
Console.WriteLine(binaryObject);
}
On Fri, Nov 15, 2019 at 5:20 PM Ilya Kasnacheev <[email protected]>
wrote:
> Hello!
>
> You can try using ignite.binary().ToBinary(obj).
>
> However, in your case, it makes sense to avoid the intermediate object
> stage directly and produce BinaryObjects from input data using builder.
>
> Regards,
> --
> Ilya Kasnacheev
>
>
> пт, 15 нояб. 2019 г. в 17:15, Manan Joshi <[email protected]>:
>
>> I am reading the data using dapper from the database i am not sure how to
>> convert fromSystem.Collections.Generic.IEnumbrable<dynamic> to
>> Apache.Ignite.Core.Binary.IBinaryObject.
>>
>> Thanks
>> Manan Joshi
>>
>> On Fri, Nov 15, 2019 at 8:46 AM Alexandr Shapkin <[email protected]>
>> wrote:
>>
>>> You can also refer to the BinaryModeExample.cs
>>> <https://github.com/apache/ignite/blob/master/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/BinaryModeExample.cs>
>>> example and the docs [1]
>>>
>>>
>>>
>>> [1] -
>>> https://apacheignite-net.readme.io/docs/binary-mode#section-creating-binary-objects
>>>
>>>
>>>
>>> *From: *Ilya Kasnacheev <[email protected]>
>>> *Sent: *Friday, November 15, 2019 4:13 PM
>>> *To: *[email protected]
>>> *Subject: *Re: Store objects as IBinaryobject in cadche
>>>
>>>
>>>
>>> Hello!
>>>
>>>
>>>
>>> You can use BinaryObjectBuilder:
>>>
>>>
>>> https://apacheignite.readme.io/docs/binary-marshaller#section-modifying-binary-objects-using-binaryobjectbuilder
>>>
>>>
>>>
>>> However, each variation of its composition is stored in schema cache,
>>> which means you should not have too many of those.
>>>
>>>
>>>
>>> It is recommended to use Map to store all variable/non-essential fields
>>> if you have a lot of them.
>>>
>>>
>>>
>>> Regards,
>>>
>>> --
>>>
>>> Ilya Kasnacheev
>>>
>>>
>>>
>>>
>>>
>>> пт, 15 нояб. 2019 г. в 16:08, Manan Joshi <[email protected]>:
>>>
>>> I would like to store any time of object into cache as IBinaryobject, so
>>> i can store cache stored in loosely bind with object. I am working with
>>> Ignite .Net. Can someone please suggest something.
>>>
>>>
>>>
>>> I need something like
>>>
>>> MyObject obj = new MyObject();
>>>
>>>
>>>
>>> obj.setFieldA("A");
>>>
>>> obj.setFieldB(123);
>>>
>>>
>>>
>>> BinaryObject binaryObj = Ignition.ignite().binary().toBinary(obj);
>>>
>>>
>>>
>>> Thanks
>>>
>>> Manan Joshi
>>>
>>>
>>>
>>