make byte[] property load lazy

前端 未结 2 806
小蘑菇
小蘑菇 2021-01-14 07:16

I\'m using EF4 Code First and I have a property:

public byte[] Bytes {get;set;}

can I make this property load lazily ( onl

2条回答
  •  别那么骄傲
    2021-01-14 07:39

    Table spliting works in EF 4.1 RC:

    public class Item
    {
        public int Id { get; set; }
        ...
        public virtual ItemDetail ItemDetail { get; set; }
    }
    
    public class ItemDetail
    {
        public int Id { get; set; }
        public byte[] Bytes { get; set; }
    }
    
    public class Context : DbContext
    {
        public DbSet Items { get; set; }
        public DbSet ItemDetails { get; set; }
    
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
    
            modelBuilder.Entity().ToTable("Items");
            modelBuilder.Entity().ToTable("Items");
            modelBuilder.Entity()
                .HasRequired(i => i.ItemDetail)
                .WithRequiredPrincipal();
        }
    }
    

提交回复
热议问题