best way for mapping poco<->vertex with dse.graph

25 views
Skip to first unread message

Roustan Thierry

unread,
Apr 26, 2019, 12:33:36 PM4/26/19
to DataStax C# Driver for Apache Cassandra User Mailing List
Hi,
What is the best way for mapping poco with vertex ?
ex:
schema:
schema.propertyKey("id").Text().single().create()
schema.propertyKey("name").Text().single().create()
schema.vertexLabel("provider").partitionKey("id").properties("name").create()
code:
 class provider
    {
        public string id {get;set; }
        public string name { get; set; }
    }
string req = string.Format(@"g.V().has('provider','id','prov1').valueMap()");
  GraphResultSet rs= session.ExecuteGraphAsync(new SimpleGraphStatement(req)).Result;

how map an instance of provider to the result of query ?

Thanks
Thierry

João Reis

unread,
Apr 29, 2019, 11:25:18 AM4/29/19
to DataStax C# Driver for Apache Cassandra User Mailing List
Hi,

The C# driver doesn't have a Mapper for graph statements. To read data from a GraphResultSet you can read the documentation here: https://docs.datastax.com/en/developer/csharp-driver-dse/2.6/features/graph-support/#handling-results

Best regards,
João Reis

Roustan Thierry

unread,
Apr 29, 2019, 1:08:48 PM4/29/19
to DataStax C# Driver for Apache Cassandra User Mailing List
Hi,
What is the best way for getting values ?
Ex: 
I have this class
 public class LocalizedString
    {
        public string lang { get; set; }
        public string localizedstring { get; set; }
    }
    [CollectionName("publicreferential")]
    public class PublicReferential
    {
        public string uid { get; set; }
        public string code { get; set; }
        public List<LocalizedString> name { get; set; }
        public PublicReferential()
        {
            name = new List<LocalizedString>();
        }
    }
i have this schema
schema.propertyKey('uid').Text().single().create()
schema.propertyKey('code').Text().create()
schema.propertyKey('lang').Text().create()
schema.propertyKey('localizedstring').Text().multiple().properties('lang').create()
schema.vertexLabel('publicreferential').partitionKey('uid').clusteringKey('code').properties('localizedstring').create()

what is the best way for query the vertex and get values into an instance of this class ?
I want to retrieve one instance of partotionkey/cluserting key or all instances of partition key
another question ?
thanks
thierry

Joao Reis

unread,
May 6, 2019, 10:42:47 AM5/6/19
to DataStax C# Driver for Apache Cassandra User Mailing List
Hi,

You will have to manually populate the instance of your class as there isn't a Mapper for DSE Graph. Try using the gremlin "valueMap" step, it may help you in this situation: http://tinkerpop.apache.org/docs/current/reference/#valuemap-step 

If you need further help with this you should contact DataStax. If you're a DataStax customer you can contact DataStax Support. Otherwise if you are interested in learning more about DataStax Enterprise feel free to contact DataStax here: https://www.datastax.com/contactus

Thanks,

João Reis  |  Senior Software Engineer - Drivers

joao...@datastax.com  |  datastax.com


--
You received this message because you are subscribed to the Google Groups "DataStax C# Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to csharp-driver-u...@lists.datastax.com.

Roustan Thierry

unread,
May 6, 2019, 11:11:55 AM5/6/19
to DataStax C# Driver for Apache Cassandra User Mailing List
Hi,
Effectively, i have used valueMap and deserialize graphnode into dictionary of collection
My code for mapping an instance of an object like this (it must be optimized...)

Sans titre.png


Thanks for your response.
Have a nice day.
Thierry







To unsubscribe from this group and stop receiving emails from it, send an email to csharp-driver-user+unsub...@lists.datastax.com.
Reply all
Reply to author
Forward
0 new messages