2011-02-16 56 views
0

这部分代码工作正常ASP.NET MVC3 System.ComponentModel.DataAnnotations和协会

[Association(Storage = "profile", ThisKey = "UserId", OtherKey = "UserId")] 
public Profile User { 
    get { return this.profile.Entity; } 
    set { this.profile.Entity = value; } 
} 

,但如果我在这个类

System.ComponentModel.DataAnnotations 

再加入,会找不到。

问题在哪里?

回答

1

奥斯汀的答案的改进是采用了using声明:

using L2SAssociation = System.Data.Linq.Mapping.Association; 

[L2SAssociation(Storage = "profile", ThisKey = "UserId", OtherKey = "UserId")] 
public Profile User 
{ 
    get { return this.profile.Entity; } 
    set { this.profile.Entity = value; } 
} 
+0

没想到你可以做到这一点,谢谢@Domenic! – Austin 2011-03-15 18:42:27

1

看起来你有两个冲突的命名空间。尝试改变协会System.Data.Linq.Mapping.Association,所以它看起来像:

[System.Data.Linq.Mapping.Association(Storage = "profile", ThisKey = "UserId", OtherKey = "UserId")] 
public Profile User { 
    get { return this.profile.Entity; } 
    set { this.profile.Entity = value; } 
}