PC Review


Reply
Thread Tools Rate Thread

Collection of custom entities

 
 
GrumpyDev
Guest
Posts: n/a
 
      6th Aug 2003
what is the best way to implement collection
of custom entities?
 
Reply With Quote
 
 
 
 
John Kennedy[MSFT]
Guest
Posts: n/a
 
      6th Aug 2003

If your "entities" are objects, just create an ArrayList and put them in
there..

ArrayList entities = new ArrayList();
entites.Add(my_entity);


 
Reply With Quote
 
DevGrumpy
Guest
Posts: n/a
 
      6th Aug 2003
My entities are objects. And I think ArrayList is very
good and simple solution. My concern is regarding type-
safety. As I understand Microsoft encourages developer to
use strong-typed classes. It also eliminates late binding
issue. To solve my problem, I wanted to create a custom
collection (inherited form CollectionBase, for example)
for each business entity. I don't know if I'm doing a
right thing.

>-----Original Message-----
>
>If your "entities" are objects, just create an ArrayList

and put them in
>there..
>
>ArrayList entities = new ArrayList();
>entites.Add(my_entity);
>
>
>.
>

 
Reply With Quote
 
Jeff Levinson [mcsd]
Guest
Posts: n/a
 
      6th Aug 2003
In general, a strongly-typed class is the way to go. The
only things you really need to be aware of are the
following:
The arraylist has less overhead, however it is much less
flexible. It can also be used as a datasource. But, it
can be referenced by index only.

The CollectionBase is flexible, can be used as a
datasource and can be accessed by Index. It is very fast
when accessing by Index. The only major drawback is that
you can't access items by Key. To do this you can do what
I do which is to create an Item(Key as string) method
which can loop through the collection looking for
your "Key" value in the objects. You can also extend it
to return the collection in a sorted order.

The DictionaryBase is the other major option. This is a
name/value collection and the items can only be accessed
by key. The collection cannot be used as a datasource and
you must use a for..each loop to look through everything.
In general, if you don't know the key then this is a bad
type of collection to use. Also, the order the data is
returned is not necessarily the order they were added in.

The choice is pretty wide open, but I'm a big fan of the
collectionbase and extending it. However the choice will
depend on the type of project and the tradeoffs you want
to make.

Jeff Levinson

Author of "Building Client/Server Applications with
VB.NET: An Example Driven Approach"






>-----Original Message-----
>My entities are objects. And I think ArrayList is very
>good and simple solution. My concern is regarding type-
>safety. As I understand Microsoft encourages developer

to
>use strong-typed classes. It also eliminates late

binding
>issue. To solve my problem, I wanted to create a custom
>collection (inherited form CollectionBase, for example)
>for each business entity. I don't know if I'm doing a
>right thing.
>
>>-----Original Message-----
>>
>>If your "entities" are objects, just create an

ArrayList
>and put them in
>>there..
>>
>>ArrayList entities = new ArrayList();
>>entites.Add(my_entity);
>>
>>
>>.
>>

>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Querying an EDM model to get collection of 2nd relation entities MarkA Microsoft ADO .NET 3 16th Jun 2009 06:18 PM
DataReader or collection of entities Andy B. Microsoft ASP .NET 4 22nd Apr 2009 12:39 AM
Help with Custom Entities chris.kennedy@peninsula-uk.com Microsoft ADO .NET 0 18th Sep 2008 05:19 PM
custom entities-dataset with plugin system Ryan Microsoft ADO .NET 0 20th Jun 2004 10:35 PM
Custom collection: how to find item in collection using custom indexer panik Microsoft C# .NET 0 21st Aug 2003 09:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:49 PM.