question

neerajk22 avatar image
neerajk22 asked Erick Ramirez commented

How do I deserialize a UDT column's byte[] data to C# entity?

Please follow below steps to repro on local

1. Create cassandra table as -

CREATE TABLE test_try_e (
    additional_details_test frozen<additional_details_test> PRIMARY KEY
)

2. Custom types as -

CREATE TYPE additional_details_test (
    products list<frozen<product_details>>,
    retailers list<frozen<retailer>>
)
CREATE TYPE retailer (
    key text,
    value text
)

3.Insert data to same table -

INSERT INTO test_try_e JSON '{"additional_details_test":{"products":[{"product_codes":"prd cda","product_name":"prd a","product_classification":"classa","quantity":1},{"product_codes":"prd cd 2","product_name":"prd name 2","product_classification":"class b","quantity":1}],"retailers":[{"key":"key1","value":"value"}]}}';

Now try to read same data using dot net client lib -

var rowSet = session.Execute("select additional_details_test from test_try_e");

This returns byte[] of column "additional_details_test " and it throws exception when we do something like this because byte[] is returned in row

var bytes = row.GetValue<AdditionalDetails>("additional_details");

"AdditionalDetails" is c# class entity

kindly provide ways to read\de-serialize this byte[] into custom class \entity

csharp driveruser-defined type
3 comments
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

neerajk22 avatar image neerajk22 commented ·

@joao.reis, Please check the small sample above to repro same issue related to #10381

0 Likes 0 ·
neerajk22 avatar image neerajk22 commented ·

Issue is resolved now. Thanks @Erick Ramirez @joao.reis for sharing documentation related to user defined type mapping.

Closing this question now. Thanks!

0 Likes 0 ·
Erick Ramirez avatar image Erick Ramirez ♦♦ neerajk22 commented ·

Good to hear!

What was the problem in the end and what did you do different to resolve it? Cheers!

0 Likes 0 ·

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

[Follow up question to #10381]

Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.