我有一个项目,其中我的一些对象正在生成 DyanmicProxy 类,并且正在跟踪它们的更改,而有些对象则没有。
示例:类别安全 - 这不会生成动态代理。(我有截图,但它会让我发布它)
tempObject {Workflow.Data.Access.CategorySecurity} - no Dynamic Proxy appended.
示例 2:MenuItem - 这是生成动态代理。
tempObject {System.Data.Entity.DyanmicProxies.MenuItem_782678127361273612738818AEDD878723827}
菜单项 - 有效
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.Data.Entity;
using Workflow.Data.Communication;
namespace Workflow.Data.Access
{
[Table("MenuItem", Schema = "wfa")]
public class MenuItem
{
[Key]
[ScaffoldColumn(false)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
[Required]
[DisplayName("Name")]
[MaxLength(250)]
public string Name { get; internal set; }
[Required]
[DisplayName("Display Name")]
[MaxLength(250)]
public string DisplayName { get; set; }
[Required]
[DisplayName("Visible")]
public bool Visible { get; set; }
[Required]
[DisplayName("Order")]
public int Order { get; set; }
[DisplayName("URL")]
public string URL { get; set; }
[DisplayName("Browser Target")]
public string BrowserTarget { get; set; }
[DisplayName("Menu")]
[InverseProperty("MenuItems")]
[UIHint("WorkflowMenu")]
public virtual Menu Menu { get; set; }
[DisplayName("Parent Item")]
[InverseProperty("ChildMenuItems")]
public virtual MenuItem ParentMenuItem { get; set; }
[DisplayName("Menu Items")]
[InverseProperty("ParentMenuItem")]
public virtual ICollection<MenuItem> ChildMenuItems { get; internal set; }
[DisplayName("Responsibilites View Access")]
[InverseProperty("MenuItems")]
public virtual ICollection<Responsibility> ViewAccess { get; internal set; }
[Required]
[DisplayName("Last Update Date")]
[ScaffoldColumn(false)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateTime LastUpdateDate { get; set; }
[Required]
[ScaffoldColumn(false)]
public int LastUpdateUserID { get; set; }
[DisplayName("Last Update Date")]
[ForeignKey("LastUpdateUserID")]
public virtual WorkflowUser LastUpdateUser { get; set; }
public MenuItem()
{
this.ChildMenuItems = new List<MenuItem>();
this.ViewAccess = new List<Responsibility>();
}
}
}
类别安全 - 不起作用
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Workflow.Data.Template;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
namespace Workflow.Data.Access
{
/// <summary>
/// Defines a Security object specific to a Category
/// </summary>
public class CategorySecurity : Security
{
[DisplayName("Category")]
//[InverseProperty("Permissions")]
[ForeignKey("CategoryID")]
public virtual Category Category { get; set; }
public int CategoryID { get; set; }
public CategorySecurity() : base() { }
}
}
安全 - 父母:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using Workflow.Data.Enum;
using System.Data.Entity;
namespace Workflow.Data.Access
{
/// <summary>
/// Defines a Security in the workflow, which will have a type to define the level of access and a List or Responsibility objects that have that access.
/// </summary>
[Table("Security", Schema = "wfa")]
public class Security
{
[Key]
[ScaffoldColumn(false)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
[Required]
public int TypeID { get; set; }
[DisplayName("Type")]
public SecurityType Type {
get
{
return (SecurityType)TypeID;
}
set
{
TypeID = (int)value;
}
}
[Required]
[DisplayName("Responsibilities")]
[InverseProperty("Security")]
public virtual ICollection<Responsibility> Responsibilities { get; set; }
public Security()
{
this.Responsibilities = new List<Responsibility>();
}
}
}