我有一大批物体,其中约有20克物体。 每一物体在一大复杂的树木结构中都有儿童物体,在那里也有阵列。 现在使用简单的<密码>myObjectType[] 我的Array
是否有更好的类型,或者我应当如何管理阵列? 99%的阵列使用都在阅读之中,但目前需要近3分钟才能填满。
EDIT:增加更多的信息。
目前的评估将所有这些数据输入巨型阵列,然后将阵列作为数据基。 然后,根据你从一些下降的箱子中选取的数据,对数据进行过滤,然后将一个子块退回到一个数据网显示。 我没有选择改写整个东西,只是把过滤器送到实际的过滤器。
EDIT:更多的信息、对拖延的担忧被拖入了一次会议。
[Serializable]
public class PartsList : System.Collections.CollectionBase
{
public virtual Part[] parts {get { return (Part[])List; } }
public new virtual int Count { get{ return this.List.Count;}}
public virtual CountryList GetCountries()
{
CountryList countries = new CountryList;
//Code removed - goes through every sub item and makes a list of unique countries...
// Yes, could have been done better.
Return countries;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
[Serializable]
public class Part
{
private int id, blah, myvariable;
private CountryList countries; //formatted the same way as this class...
private YearList years;
private ModelList models;
private PriceHistoryList priceHistoryList;
// there are a couple more like these...
}
This is why it takes 3minutes to load. - 20k parts - 1-2 countries per part - 1-10 years per part - 1-12 models per part - 1-10 price history per part
When I stop the debugger on this line: PartsList mylist = new PartsList; //populate the list here if (list.Count != 0 ) <- the debugger takes 13 seconds to get off this line after hitting f10. doing a "quick watch" on list just gives me an error for the counts value.
我真心想的是,如果把阵列放在内部,则有更好的变式,以取代阵列......
UPDATE Jan 29 2010 Did some searching and it appears that due to the object designs, it is lazy loading one object at a time into memory, causing a TON of sql calls to be fired. Also the Count seems to take so long because a combo of using CollectionBase and complex objects where it is retrieving each object, counting it then going to the next. Plan now IS to move app to 2008 (.net 3.5 from 1.1) and do a rewrite of the back end of the application so that it does not pre-load 350mb into memory...
感谢大家的投入。