Is there any better way to Write UDTMaps is the same way as Tables using Cassandra Database with C# Driver
Suppose there is a Table called Users(Id, name text, Address frozen )in Cassandra Database. now to map this to C# for Tables I can write as below
public class AppMappings : Mappings
{
public AppMappings()
{
For<User>()
.TableName("Users")
.Column(u => u.Id, cm => cm.WithName("userId"))
.Column(u => u.Name, cm => cm.WithName("username"))
.Column(u => u.AddressDetails , cm => cm.WithName("address"))
.PartitionKey(u=> u.Id);
}
}
public class User
{
public Guid Id {get;set;}
public string Name {get;set;}
public Address AddressDetails {get;set;}
}
public class Address {
public string State {get;set;}
public string City {get;set;}
}
Now I can Apply any Configurations with Single Class AppMappings , it can have many mappings with tables. With this one line I can initialize all mappings
MappingConfiguration.Global.Define<AppMappings>();
but inroder to apply UDT I need to add the below line manually.
session.UserDefinedTypes.Define(UdtMap.For<Address>("address_udt"));
Assume I have 10/20 UDTs then I need to add this line for every UDT. instead is there any way to add UDT Mappings in one place like Mappings? or better approach to add UDT Mappings ?