user146376
user146376

Reputation:

Subsonic 2: object brings back multiple database tables info

I ask subsonic for a table in my database. It returns the table and all other tables connected threw foreign keys,

Can't I stop it bringing back all the extra table info?

Here is my code:

[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;
}

The dealEquipmentList that I return is suppose to only contain my foreignkey to supplier, but the supplier tables info is also included.

This is a problem since the supplier object contains huge binary images.

I try to set it to null but it is ignored.

Any ideas?

Upvotes: 1

Views: 190

Answers (1)

krdluzni
krdluzni

Reputation: 797

It doesn't actually contain the object. What happens is that when you access the Supplier property on the DealEquipment it sends a new request to the DB to fetch the Supplier with the ID you chose, via FetchByID(int). You can take a look at the generated classes to see with your own eyes, if you'd like.

(This answer is based on version 2.1.1.0 .)

Upvotes: 2

Related Questions