【发布时间】:2015-12-09 01:59:43
【问题描述】:
我不得不使用关系对象解决多对多数据库设计,但我需要确保没有重复。我曾希望我可以将相关对象的集合定义为 HashSet,但 ServiceStack 不喜欢它。这是我用于 OrmLite 的 POCO 的简化版本:
public class Foo
{
public int Id { get; set; }
[Reference]
public HashSet<FooToBar> FooToBars { get; set; }
}
public class Bar
{
public int Id { get; set; }
public string Name { get; set; }
}
public class FooToBar
{
public int Id { get; set; }
[References(typeof(Foo))]
public int FooId { get; set; }
[References(typeof(Bar))]
public int BarId { get; set; }
// This is the requirement that makes it a little odd
public string Option { get; set; }
}
类Foo 只能有唯一的Bars 和与之相关的Options。从 C# 的角度来看,HashSet 对此非常有用,但 ServiceStack 正在寻找 HashSet 类型上的相关实体 ID。
我有什么方法可以做到这一点不会让 ServiceStack 发疯吗?
【问题讨论】:
标签: c# servicestack ormlite-servicestack