我想像
一样使用它@foreach (StepArticles obj in data)
{
@obj.ArticlesDescriptions.Desc
}
我对这种方法有疑问
return this._StepArticles.Entity;
抛出异常:System.InvalidOperationException:后续事件包含多个元素
通常使用与Id的关联来进行iam,并且所有这些都在OneToOne中起作用OneToMany,但是在这种情况下,我需要与Article-Artikl(varchar)关联使用
我认为问题将在某个地方,所以我想问你...很多:)
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="StepArticles_ArticlesDescriptions", Storage="_StepArticles", ThisKey="Artikl", OtherKey="Article", IsForeignKey=true)]
public StepArticles StepArticles
{
get
{
return this._StepArticles.Entity;
}
set
{
StepArticles previousValue = this._StepArticles.Entity;
if (((previousValue != value)
|| (this._StepArticles.HasLoadedOrAssignedValue == false)))
{
this.SendPropertyChanging();
if ((previousValue != null))
{
this._StepArticles.Entity = null;
previousValue.ArticlesDescriptions = null;
}
this._StepArticles.Entity = value;
if ((value != null))
{
value.ArticlesDescriptions = this;
this._Artikl = value.Article;
}
else
{
this._Artikl = default(string);
}
this.SendPropertyChanged("StepArticles");
}
}
}
基数设置为onetoone
编辑-> 因此,实际上问题不在c#或linq上,因为我将对象序列化为json JsonConvert.SerializeObject(stepArticles); 因此,如果我删除所有正常工作(但我需要该json:))
错误: {“检测到类型为'Models.StepArticles'的属性'StepArticles'的自引用循环。路径'[0] .ArticlesDescriptions'。”
答案 0 :(得分:0)
替换:
return this._StepArticles.Entity;
具有:
return this._StepArticles;