나는 사용자 정의 데이터 액세스 레이어를 개발하고 있어요 내가 가진 무엇 breeze.js 에서 소비 될 : 모델 : 공용 클래스 제품을 { [키] public int ProductId {get; 세트; } 공개 문자열 Upc {get; 세트; } public string Name {get; 세트; } public decimal MsrpPrice {get; 세트; } public int Quantity {get; 세트; }Breeze.js/NET + EF 복잡한 객체의 행동은
public virtual ICollection<ProductFeature> Features { get; set; }
public virtual B2BCategory InB2BCategory { get; set; }
public virtual ICollection<ImageDescriptor> Images { get; set; }
public int CategoryId {get; set;}
} 공용 클래스 ProductFeature { 공공 INT의 제품 일련 {얻을; 세트; } public string Name {get; 세트; } public string GroupName {get; 세트; } public string Operation {get; 세트; } public decimal Value {get; 세트; } }
public class ImageDescriptor
{
public int ProductId { get; set; }
public string Uri { get; set; }
public DateTime Updated { get; set; }
public bool IsDefault { get; set; }
}
컨텍스트 공급자 : 공용 클래스 ProductContextProvider : ContextProvider { 개인 읽기 전용 ProductRepository의 환매 특약 = 새로운 ProductRepository();
product.Features = new Collection<ProductFeature>();
product.Images = new Collection<ImageDescriptor>();
…
var imgd = new ImageDescriptor
{
ProductId = product.ProductId,
Updated = DateTime.Now,
Uri = defsmall,
IsDefault = !product.Images.Any()
}
product.Images.Add(imgd);
…
var pf = new ProductFeature
{
ProductId = product.ProductId,
GroupName = "Size",
Name = size,
Value = size == "Small" ? new decimal(.75):size == "Medium" ? new decimal(1.3):new decimal(1.8),
Operation = "*"
};
product.Features.Add(pf);
가 완전히 말하자면, 3 개 제품 기능 및 제품 항목 당 2 개 이미지가 있습니다 :
public IQueryable<B2BCategory> Categories
{
get { return repo.Categories.AsQueryable(); }
}
public IQueryable<Product> Products
{
get
{
return repo.Products.OrderBy(p => p.ProductId).AsQueryable();
}
}
protected override string BuildJsonMetadata()
{
var contextProvider = new EFContextProvider<ProductMetadataContext>();
return contextProvider.Metadata();
}
protected override void SaveChangesCore(SaveWorkState saveWorkState)
{…
}
// No DbConnections needed
public override IDbConnection GetDbConnection()
{
return null;
}
protected override void OpenDbConnection()
{
// do nothing
}
protected override void CloseDbConnection()
{
// do nothing
}
}
internal class ProductMetadataContext : DbContext
{
static ProductMetadataContext()
{
Database.SetInitializer<ProductMetadataContext>(null);
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new ProductFeatureConfiguration());
modelBuilder.Configurations.Add(new ImageDescriptorConfiguration());
}
public DbSet<Product> Products { get; set; }
public DbSet<B2BCategory> Categories { get; set; }
}
internal class ImageDescriptorConfiguration : EntityTypeConfiguration<ImageDescriptor>
{
public ImageDescriptorConfiguration()
{
// I tried to mess up with key orders
HasKey(i => new { i.Uri, i.ProductId});
}
}
internal class ProductFeatureConfiguration : EntityTypeConfiguration<ProductFeature>
{
public ProductFeatureConfiguration()
{
HasKey(f => new { f.ProductId, f.Name });
}
}
가 나는 기능 및 이미지 직접 제품의 속성을 채우고 있어요.
클라이언트 측에서는 다음과 같이 쿼리합니다. return entityQuery.from ('Products'). (EntityManager) .execute();
그리고 ... 매우 이상한 점이 있습니다. images 속성에 빈 배열이 들어 있고 features 속성에는 5 배열이 포함되어 있습니다. 요소 - ProductFeature 유형 3 개와 ImageDescriptor 유형 2 개. 이것이 버그라고 생각합니다. 제발 도와 주실 수 있습니까?