Subsonic 2:对象带回多个数据库表信息

时间:2009-07-28 13:09:08

标签: sql subsonic

我在数据库中询问亚音速表。 它返回表,并且连接的所有其他表都抛出了外键,

我不能阻止它带回所有额外的表信息吗?

这是我的代码:

[WebMethod]
[ScriptMethod]
public List<DealEquipment> GetDealEquipment(Guid DealID)
{
    List<DealEquipment> dealEquipmentList = new List<DealEquipment>();
    Deal deal = new Deal(DealID);
    DealEquipmentCollection dealEquipmentCollection = deal.DealEquipmentRecords();

    foreach (DealEquipment dealEquipment in dealEquipmentCollection)
    {
        DealEquipment dealEquipmentTemp = dealEquipment;
        DealEquipmentSerialNumberCollection dealEquipmentSerialNumberCollection =     new      DealEquipmentSerialNumberCollection().Where(DealEquipmentSerialNumber.Columns.FkDealEquipmentID, Comparison.Equals, dealEquipmentTemp.PkDealEquipmentID).Load();
        dealEquipmentTemp.objSerialNumber = new List<DealEquipmentSerialNumber>();
        foreach (DealEquipmentSerialNumber dealEquipmentSerialNumber in dealEquipmentSerialNumberCollection)
        {
            dealEquipmentTemp.objSerialNumber.Add(dealEquipmentSerialNumber);
        }
        dealEquipmentList.Add(dealEquipmentTemp);
    }

    return dealEquipmentList;
}

我返回的dealEquipmentList假设只包含我的外键给供应商, 但也包括供应商表信息。

这是一个问题,因为供应商对象包含巨大的二进制图像。

我尝试将其设置为null但忽略它。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

它实际上并不包含该对象。当您在DealEquipment上访问Supplier属性时,它会向DB发送一个新请求,通过FetchByID(int)获取您选择的ID的供应商。如果你愿意的话,你可以亲眼看看生成的类。

(此答案基于版本2.1.1.0。)