【发布时间】:2020-08-02 02:15:14
【问题描述】:
我在 Cassandra 中创建了 UDT
员工 UDT
对应的c#类如下:
public class Employee
{
public int emp_id { get; set; }
public string emp_name { get; set; }
public int emp_age { get; set; }
}
以及以下代码将UDT与相应的c#类连接和映射:
var cluster = Cluster.Builder()
.AddContactPoint("localhost")
.Build();
ISession session = cluster.Connect("firstkeyspace");
//session.UserDefinedTypes.Define(UdtMap.For<Employee>().Automap());
session.UserDefinedTypes.Define(UdtMap.For<Employee>("employee", keyspace: "firstkeyspace"));
var rs = session.Execute("select * from employee");
在检索时使用以下代码行:
Employee employee = row.GetValue<Employee>("employee");
我收到以下错误:
请看一下,如果有任何遗漏,请告诉我。
【问题讨论】: