private string GetListTypeName(ColumnDescOrTableColumn tableColumn) { var typeInfo = ((Cassandra.ListColumnInfo)tableColumn.TypeInfo); var fakeTableColumn = new TableColumn { TypeCode = typeInfo.ValueTypeCode, TypeInfo = typeInfo, Keyspace = this.keySpaceName, Table = tableColumn.Table, }; string memberType = null; if (typeInfo.ValueTypeCode == Cassandra.ColumnTypeCode.Udt) { fakeTableColumn.TypeInfo = typeInfo.ValueTypeInfo; this.isFrozen = true; memberType = this.GetCSharpTypeName(fakeTableColumn); } else { memberType = this.GetCSharpTypeName(fakeTableColumn); } return(memberType != null ? $"List<{memberType}>" : null); }
private string GetCSharpTypeName(ColumnDescOrTableColumn tableColumn) { Func <ColumnDescOrTableColumn, string> csharpTypeNameFunc; if (this.cassandraToCSharpTypeEquivalency.TryGetValue(tableColumn.TypeCode, out csharpTypeNameFunc)) { return(csharpTypeNameFunc(tableColumn)); } return(null); }
private string GetUDTTypeName(ColumnDescOrTableColumn tableColumn) { var typeInfo = ((Cassandra.UdtColumnInfo)tableColumn.TypeInfo); var typeName = typeInfo.Name; if (typeName.Contains(".")) { typeName = typeName.Split(".").ToList().Last(); } var className = Utils.Utils.CSharpifyName(typeName); var properties = new List <string>() { "" }; var udtMappings = new List <string>(); foreach (var field in typeInfo.Fields) { var columnNameCS = Utils.Utils.CSharpifyName(field.Name); var csharpTypeName = GetCSharpTypeName(field); if (csharpTypeName != null) { properties.Add($" public {csharpTypeName} {columnNameCS} {{ get; set; }}"); udtMappings.Add($" .Map(a => a.{columnNameCS}, \"{field.Name}\")"); } } var udtMapping = $@" public static void Map(Cassandra.Session session) {{ session .UserDefinedTypes .Define( Cassandra .UdtMap .For<{className}>(""{typeName}"") {string.Join("\n", udtMappings)} ); }}"; this.CreateCSFile(className, properties, "", "", udtMapping); if (!this.udtClasses.Contains(className)) { this.udtClasses.Add(className); } return(className); }