0
엔티티의 단일 또는 모음 저장/업데이트 요구 사항이 있습니다. 나는 똑같은 클래스를 writtrn있다. 필자는 전체적으로 부분적으로 저장되는 두 개의 엔티티 만 사용했습니다. 엔티티엔티티 업데이트를위한 디자인 패턴
public static class ProductFactory
{
public static void Save(Product prod)
{
//Save Product table
}
}
public static class SupplierFactory
{
public static void Save(Supplier supp)
{
//Save Supplier table
}
}
//Method to Save All ENTITIES
public static class DataFactory
{
public static void Save(Data data)
{
//Save Data which Consists Product and Supplier
ProductFactory.Save(data.prod);
SupplierFactory.Save(data.supp);
}
}
//Implemention of Save
Product prod = new Product() ;
Supplier supp=new Supplier();
Data data=new Data() ;
//Saving Product individually
ProductFactory.Save(prod);
//Saving Supplier individually
SupplierFactory.Save(supp);
//Saving Data which Consists Supplier and Product
DataFactory.Save(data);
는 사람이 더 나은 디자인을 제안 수를 저장하는
public class Supplier
{
}
public class Product
{
}
public class Data
{
public Product prod { get; set; }
public Supplier supp { get; set; }
}
// 대응 방법 : 그러나 실제 경우에 이상의 개체가 될 수 있을까? Product/Supplier 위에 더 많은 엔티티가있을 수 있습니다.
저장소 패턴을 사용할 때는 정적을 사용하지 마십시오. 또한 repo 인터페이스는 항상 orm 엔티티가 아닌 비즈니스 객체와 함께 작동합니다. orm은 저장소의 구현 세부 사항이며 누출되지는 않습니다. – MikeSW