About the author

Miron Abramson
Software Engineer,
CTO at PixeliT
and .NET addicted for long time.
Open source projects:
MbCompression - Compression library

Recent comments



The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2018

Creative Commons License

Blog Flux Directory
Technology Blogs - Blog Top Sites

Simple Generic Business Entities

"Business Entites" are widly commonly use everywhere. Sometimes the entities are very big and contains a lot of methods and properties, but most of the time, they are basicly objects that holds data in easier and cleaner way than DataTables/DataSets. Sometimes you have entity for specific type such "Customer", "Laboratory", "Shop" or whatever, but lots of time you just need to load and hold data that is not from spesific type. Good way to hold such "un typed data" is using Generic. A "Generic Entity" that can hold any kind of data you need in the moment. For example, I create Generic entity called "Quadruple" that have 4 properties that will be from type you choose. If you create an instance of this entity like this:

Quadruplet<int,string,int,string> q1 = new Quadruplet<int,string,int,string>();

Quadruplet<bool,bool,Array,string> q2 = new Quadruplet<bool,bool,Array,string>();

q1 will be entity that can hold int, string, int & string and q2 will be entity that hold bool, bool, Array, string. No casting is needed.

List<Quadruplet<int, string, int, string>> quadrupletList = new List<Quadruplet<int, string, int, string>>();

quadrupletList  will be List of object from type Quadruplet<int,string,int,string>.  This kind of entitis can be very usuful in any kind of application, and it very reusable from application to another. 

In the file below, there are 4 entites: Duplet - hold 2 objects from any kind, Triplet 3 object (I know there is such class in 'System.Web.UI' but it holds 3 objects from the type 'Object' and casting will be needed),  Quadruplet for 4 objects and Quintet for 5. All those entities contains basic needed methods as Equals(object), operator ==, operator != and GetHashCode().

Those entities are NOT comming to replace the  "Customer", "Laboratory", "Shop" or any other specific needed entity. They are to help working with "un type" of data. Where the data is not from specific type or you don't want to make specific entitiy for that data.

SimpleGenericBusinessEntities.zip (4.26 kb)

Currently rated 4.4 by 7 people

  • Currently 4.428571/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by Miron on Saturday, February 16, 2008 6:57 AM
Permalink | Comments (1) | Post RSSRSS comment feed