我正在使用ServiceStack v4.x VS2013
默认情况下,ServiceStack ORMLite(SqlServer)使用" NOT NULL"定义外键。 以下代码生成一个外键" FooId(FK,long,not null)" 如何告诉ServiceStack这个外键可能为空?
public class Blah
{
[AutoIncrement]
public long Id { get; set; }
public string Name { get; set; }
[References(typeof(Foo))]
public long FooId { get; set; }
}
public class Foo
{
[AutoIncrement]
public long Id { get; set; }
public string Description { get; set; }
}
答案 0 :(得分:1)
要在OrmLite中指定值类型可以为空,请在C#中使其可为空:
public class Blah
{
[AutoIncrement]
public long Id { get; set; }
public string Name { get; set; }
[References(typeof(Foo))]
public long? FooId { get; set; }
}