我想在一张大约有 600 张桌子的桌子上使用 PetaPoco,但我只想映射少数几张桌子。
有没有办法明确说明我想要映射的表?t4 模板 ( tables["tablename"].Ignore = true
) 中的配置并不能真正扩展到这种方法?
我想在一张大约有 600 张桌子的桌子上使用 PetaPoco,但我只想映射少数几张桌子。
有没有办法明确说明我想要映射的表?t4 模板 ( tables["tablename"].Ignore = true
) 中的配置并不能真正扩展到这种方法?
我最终这样做了:
Tables tables = LoadTables();
foreach(Table t in tables)
{
if(!t.Name.Contains("all_user_group"))
{
t.Ignore = true;
}
}
我做过类似的事情
var tablesToLoad= new string[] {
"TableOne",
"TableTwo",
"ViewOne",
"Etc" };
var tables = LoadTables();
foreach(var t in tables)
{
if(!tablesToLoad.Contains(t.Name))
{
t.Ignore = true;
}
}
为避免 T4 模板填充忽略分配,我创建了一个新的数据库用户,该用户只能访问我需要的表。
然后我将 T4 模板与数据库用户连接起来,PetaPoco 只看到了我需要的表。