SubSonic 3 isn't generating Foreign Key tables as a property
Basically, 开发者_运维百科I'm having the same problem as detailed here, but in SubSonic 3.0. Unfortunately, I can't figure out how to change the provider in SubSonic 3.0.
Is this something I need to change in the MySQL.ttinclude, Settings.ttinclude or one of the T4 templates? Or does it go in config somewhere?
Thoughts? Suggestions?
I found this that says that it's as designed. I can't imagine why. I changed the Classes.tt file to generate a single mapping. The relevant code is below. However, this relies on the fact that all my PKs are named Id, but you should be able to get the idea.
Before the IQueryable<> generation part:
if (fk.ThisColumn == "Id")
{
//This is where the standard IQueryable goes
} else {
//This is what I added
public <#= fk.OtherTable #> <#= fk.OtherTable #>
{
get
{
var db=new <#=Namespace #>.<#=DatabaseName#>DB();
return from items in db.<#=fk.OtherQueryable #>
where items.<#=fk.OtherColumn#> == _<#=fk.ThisColumn#>
select items;
}
}
}
Hopefully that helps. I'm trying to figure out now to do many to many tables now :/
I am using Subsonic 2.2 and I am facing the same issue, but this worked on my problem: Apart from original provider MySqlDataProvider
, there is an extended version: MySqlInnoDBDataProvider
So in your web.config, making sure the provider is choosn:
<add name="MyProvider"
type="SubSonic.MySqlInnoDBDataProvider, SubSonic"
connectionStringName="WriteConnectionString"
generatedNamespace="AttendAnywhere.Data"
generateLazyLoads="true"
extractClassNameFromSPName="true" />
精彩评论