c# - If Entity Framework data obtained via navigation properties isn't empty, it causes error -
i'm having wcf service, included .edmx file, generated existing info base. @ begging there problem, @ wcf level info obtained , sent, in mvc controller appeared error connection closed, understood because of configuration.proxycreationenabled = true; , when changed false, seemed work fine, until i've tried info multiple tables, linked.
so, .edmx file, there auto generated classes userprofile , roles
public partial class userprofile { public userprofile() { this.webpages_roles = new hashset<webpages_roles>(); } public int userid { get; set; } public string username { get; set; } public virtual icollection<webpages_roles> webpages_roles { get; set; } } and
public partial class webpages_roles { public webpages_roles() { this.userprofiles = new hashset<userprofile>(); } public int roleid { get; set; } public string rolename { get; set; } public virtual icollection<userprofile> userprofiles { get; set; } } also, in database there table consist of
userid roleid as understood, called navigation property. problem - when i'm trying send info gathered like:
list<userprofile> result = context.userprofiles .include(s => s.webpages_roles) .where(z => z.userid == id) .tolist(); i'm receiving same error configuration.proxycreationenabled true. i've noticed in case webpages_roles collection empty, works fine, if there @ to the lowest degree 1 record - i'm receiving error message. please help me, solve it.
also, i've configured service write exceptions, , message was
webpages_roles' contains cycles , cannot serialized if reference tracking disabled.'.
solution decorate userprofile , webpages_roles classes [datacontract(isreference = true)] attribute
the reply found in this arcticle
c# entity-framework wcf linq-to-entities navigation-properties
No comments:
Post a Comment