C# 从不同来源创建摘要类

C# 从不同来源创建摘要类,c#,wcf,class,C#,Wcf,Class,我试图为我的项目建立一个业务逻辑。该项目使用4种不同的WCF资源,所有这些资源都提供类似的产品。我想实现一个涵盖这4种产品的产品,例如: class WCF1.Product { string Name; int ID; string Image; string Brand; } class WCF2.ProductDetail { string ProductName; int Identity; string Photo; s

我试图为我的项目建立一个业务逻辑。该项目使用4种不同的WCF资源,所有这些资源都提供类似的产品。我想实现一个涵盖这4种产品的产品,例如:

class WCF1.Product {
    string Name;
    int ID;
    string Image;
    string Brand;
}

class WCF2.ProductDetail {
    string ProductName;
    int Identity;
    string Photo;
    string Color;
}

class WCF3.ProductInfo {
    string Name;
    int ID;
    string Image;
}

class WCF4.Product {
    string ProductName;
    int Identity;
    string Photo;
    double Weight;
}
至少我想要

class Product {
    string Name;
    int ID;
    string Photo;
    string Brand;
    string Color;
    double Weight;
}
在这两个类上,ID或Identify表示每个产品的唯一ID。所以,我如何从所有源类中获得这样的摘要或覆盖类


提前谢谢

你就不能用手画地图吗

public class ProductBO
{
    Product GetProduct(int ID)
    {
        // make service calls against the ID and populate DTOs from services
        WCF1.Product p1 = new WCF1.Product();
        WCF2.Product p2 = new WCF2.Product();
        WCF3.Product p3 = new WCF3.Product();
        WCF4.Product p4 = new WCF4.Product();

        p1 = WCF1.GetProduct(ID);
        p2 = WCF2.GetProduct(ID);
        p3 = WCF3.GetProduct(ID);
        p4 = WCF4.GetProduct(ID);

        // then map each to your domain Product object
        Product p = new Product();
        p.Name = p1.Name;
        p.ID = ID;
        p.Color = p2.Color;
        p.Brand = p1.Brand;
        p.Photo = p2.Photo;
        p.Weight = p4.Weight;

        return p;
    }
}

我没有考虑名字、照片、图像等的不同,但是如果它们不同,那么你需要考虑使用哪种WCF源,连接,等等。

你用这一个替换4个类吗?a会有帮助吗?@Harrison在每个WCF类ID或标识已经唯一的情况下,我需要从这4个类创建最后一个类是的,我想我应该用所需的案例映射这些类。谢谢