如何使用 PetaPoco 显式包含映射表

发布于 2024-12-03 20:47:04 字数 143 浏览 5 评论 0原文

我想在大约有 600 个表的表上使用 PetaPoco,但我只想映射少数表。

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

I want to use PetaPoco on a table that has circa 600 tables, but I only want to map a handful of the tables.

Is there a way to explicitly state the tables I want mapping? The config in the t4 template (tables["tablename"].Ignore = true) doesn't really scale to this approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

2024-12-10 20:47:04

我最终这样做了:

Tables tables = LoadTables();

 foreach(Table t in tables)
    {
        if(!t.Name.Contains("all_user_group"))
        {
            t.Ignore = true;   
        }
    }

I ended up doing it like this:

Tables tables = LoadTables();

 foreach(Table t in tables)
    {
        if(!t.Name.Contains("all_user_group"))
        {
            t.Ignore = true;   
        }
    }
烟─花易冷 2024-12-10 20:47:04

我做过类似的事情

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

var tables = LoadTables();

foreach(var t in tables)
{
  if(!tablesToLoad.Contains(t.Name))
  {
    t.Ignore = true;
  }
}

I have done something similar

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

var tables = LoadTables();

foreach(var t in tables)
{
  if(!tablesToLoad.Contains(t.Name))
  {
    t.Ignore = true;
  }
}
墨小沫ゞ 2024-12-10 20:47:04

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

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

To avoid having a T4 template filled with ignore assignments, I made a new database user that only had access to the tables I needed.

Then I connected the T4 template with the database user and PetaPoco only saw the tables I needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文