简体   繁体   English

由于跨不同模式的相同对象名称,子模式转换在T4模板中失败

[英]Subsonic transformations failing in T4 template due to same object name across different schemas

i have core T4 templates in subsonic to create my DAL. 我有亚音速的核心T4模板来创建我的DAL。 Connection strings which i have users which have selective access to different schemas in the database. 连接字符串,我有用户可以选择性地访问数据库中的不同模式。

problems arise when i try to generate my DAL partial classes for a user which has access to two schemas both having an object (say a table) with the same name. 当我尝试为有权访问两个模式的用户生成我的DAL部分类时会出现问题,这两个模式都有一个具有相同名称的对象(比如一个表)。

so if my user has access to MYSCHEMA1 and MYSCHEMA2 and both of these schemas contain an object with the name COMMONOBJECT, the transformations in subsonic fails. 因此,如果我的用户可以访问MYSCHEMA1和MYSCHEMA2,并且这两个模式都包含名为COMMONOBJECT的对象,则亚音速中的变换将失败。

here's the error i get 这是我得到的错误

Running transformation: System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.VisualStudio.TextTemplating1A7026BAC93607B56DDB080E7C2EC2DB.GeneratedTextTransformation.LoadTables()
   at Microsoft.VisualStudio.TextTemplating1A7026BAC93607B56DDB080E7C2EC2DB.GeneratedTextTransformation.TransformText()
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)

i do not want to delete one of those objects. 我不想删除其中一个对象。

is there a way i can configure subsonic to use 'fully qualified names' like MYSCHEMA1.COMMONOBJECT to use when running transformations? 有没有办法我可以配置亚音速使用MYSCHEMA1.COMMONOBJECT等“完全限定名称”来运行转换时使用?

修改你的tt模板,首先找出模式,然后使用它来为你的例子中的对象添加前缀 - 表格,例如myschema.employee

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM