我可以从一个poco填充多个表吗?

时间:2018-01-17 13:51:10

标签: c# sql-server petapoco micro-orm

我正在调查使用ORM访问我们的DataVault。到目前为止,PetaPoco看起来最有希望,但我并不是那个人。

我们识别的大多数对象都嵌入在Hub和Sat的组合中,其中Hub包含BusinessKey,Sat包含其他信息。在poco中它看起来像这样(简化):

// hub: H_Client
// sat: HS_Client
class Client 
{
     public string ClientId_BK  { get; set; }  // BusinessKey in the Hub

     public long H_Client_SeqId { get; set; }  // PK/Identity in Hub, FK in the Sat

     public string? Address     { get; set; }  // additional attr. in the Sat
     public string? Phone       { get; set; }  // additional attr. in the Sat
     /* and a lot more attributes */
}

因此,每当我们谈论客户时,它总是涉及Hub和Sat的组合。 通常,ORM一次只能连接一个表,但这对于datavaults来说并不是很有用:您总是希望查询或插入具有适用的Sat的集线器。

是否可以从一个poco更新或插入多个表?

1 个答案:

答案 0 :(得分:0)

使用ResultColumn检索信息是微不足道的,但是对于插入/更新,您需要添加自己的逻辑(在两个表中插入带有事务等)。

请记住,这种小型,高性能的ORM应该很简单。

相关问题