آereは私のストアクラスです:
public class Store : IEntity, IAuditedEntity
{
public Store();
public double CommissionRate { get; set; }
public bool CommissionEnabled { get; set; }
public virtual ICollection<User> StoreUsers { get; set; }}
そして、これが私のユーザークラスです:
パブリッククラスユーザー:IdentityUser、IEntity {public User();
[StringLength(50)]
public string CustomerAppToken { get; set; }
[StringLength(256)]
public string StoreDeviceId { get; set; }
[StringLength(256)]
public string CustomerDeviceId { get; set; }
public bool StoreAppInstalled { get; set; }
public bool WinAppInstalled { get; set; }
そのストアのユーザーが持っている場合は、gridview列に「はい」を表示したいwinappinstall = true
と思います。そのためのコードは次のとおりです。
cols.Add("CustomerAppInstalled").WithHeaderText("HAs App?")
.WithValueExpression(p => p.OnlinePaymentEnabled.ToBoolean() ? "yes" : "no")
.WithVisibility(visible: true, allowChangeVisibility: true)
.WithSorting(true);
しかし、それは例外をスローします:
objectcontextインスタンスが破棄されました
私の解決策は、.Includeを使用して遅延読み込みを無効にすることでしたが、どこにあるのかわかりませんか?
コード内の特定のプロパティの遅延読み込みをオフにする場合は、マークを付けます
public virtual ICollection<User> StoreUsers { get; set; }}
なので
public ICollection<User> StoreUsers { get; set; }}
Configurationプロパティのフラグをfalseに設定することで、コンテキスト内のすべてのエンティティの遅延読み込みをオフにできます。データベースコンテキストで、フラグを設定します。
this.Configuration.LazyLoadingEnabled = false;
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加