2

我想在一张大约有 600 张桌子的桌子上使用 PetaPoco,但我只想映射少数几张桌子。

有没有办法明确说明我想要映射的表?t4 模板 ( tables["tablename"].Ignore = true) 中的配置并不能真正扩展到这种方法?

4

3 回答 3

4

我最终这样做了:

Tables tables = LoadTables();

 foreach(Table t in tables)
    {
        if(!t.Name.Contains("all_user_group"))
        {
            t.Ignore = true;   
        }
    }
于 2011-09-12T10:56:30.323 回答
2

我做过类似的事情

var tablesToLoad= new string[] {
 "TableOne",
 "TableTwo",
 "ViewOne", 
 "Etc"    }; 

var tables = LoadTables();

foreach(var t in tables)
{
  if(!tablesToLoad.Contains(t.Name))
  {
    t.Ignore = true;
  }
}
于 2012-06-06T16:37:52.267 回答
1

为避免 T4 模板填充忽略分配,我创建了一个新的数据库用户,该用户只能访问我需要的表。

然后我将 T4 模板与数据库用户连接起来,PetaPoco 只看到了我需要的表。

于 2013-04-23T19:11:13.023 回答