asp.net - How to create multiple classes in single DTO class? -
i used making separate business object , list<> classes db tables. have basic task in hand displaying list of year search box or having values in drop down.
right ending lot of separate classes , list classes<> these basic operations.
how can make single class basic tasks these using generics? want have single class methods current year, employee names, department name/code, title etc. please give me example. using .net 2.0.
edit after searching, found can achieve similar tasks creating dto namespace.
what don't right how create multiple classes inside dto class. 1 class returning 'year', 1 'employee name/code' , on inside single dto class.
you can map classes db table manually or can use nhibernate advanced orm works quiet .net 2.0.
basically can map plain c# classes db table using simple xml mapping file.
example class called product can
public class product { public guid id { get; set; } public string name { get; set; } public string category { get; set; } public bool discontinued { get; set; } }
can mapped db table using following mapping file.
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="firstsolution" namespace="firstsolution.domain"> <class name="product"> <id name="id"> <generator class="guid" /> </id> <property name="name" /> <property name="category" /> <property name="discontinued" /> </class> </hibernate-mapping>
this has support .net collections. there sure learning curve productivity benefit worth.
more example can found here.
http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application.aspx
Comments
Post a Comment