web services - NHibernate Projection to DTO -


I am unfamiliar with NHibernate launch I am trying to use it, so I have a list & lt;> Rather an ILIST & lt;> I do not have much luck with presenting DTO yet. I have the following query and domain object. I started by trying to get the list of commands given to just one employee. I am here. I am looping through the resulting list and adding it to a list because I want to be able to sort this list. Can anyone tell me how far am I with launch? I searched and found some examples which are not similar to me. In fact .. I just want to make a list of DTO.

Thank you!

  Public listing & lt; Employee Order & gt; GetEmployessOrdersDTO (int empid) {var emporders = new list & lt; Employee Order & gt; (); Select Icricetia criteria = NHibernateSessionManager.Instance.GetSession (). CreateCriteria (typef (order)) .Care credit ("employee") Add (expression .eec ("employee id", empid)); Select criteria. Projection (projection projection list). Add (Projection Properties ("Products"), "Ordered Products")); CriteriaSelect.SetResultTransformer (NHibernate.Transform.Transformers.AliasToBean (typeof (EmployeeOrder))); CriteriaSelect.List & LT; EmployeeOrder & gt; (); Fresh (Diverse order in impressions) {emporders.Add (order); } The edge of the return; }  

Order:

  public class commands {public virtual int orderID {get; Private Set;} Receive Public Virtual String Customer ID { Set; } Received public virtual date time order date; Set; } Public Virtual Date Time Required {get; Set; } Public virtual date time shipping date {get; Set; } Public Virtual Employee Employee {Received; Set; } Public Virtual ILILT & lt; Products & gt; Product {Received; Private set; }}  

Employee:

  Public class employees {Public Virtual Incharge / ID; Private set;} Public virtual string LastName {get; Set;} public virtual string first name {get; Set;} public virtual string city {get; Set; } Public Virtual Date Time HireDate {get; Set; } Public Virtual String Title {get; Set; } Public Virtual Assistant & lt; Order & gt; Order Received; Private set; }}  

Employee Order DTO:

  Public class employee employee {Name of public virtual string worker {get; Set; } Public Virtual String EmployeeTitle {get; Set; } Public Virtual Date Time Required {get; Set; } Public Virtual List & lt; Products & gt; Order Product (Receive; Set;}}  

In hibernate 2.1, list () Method is actually a list type already, so that you can simply enter:

  var list = (list & lt; employee order & gt;) select criteria.list & lt ; Employee Order & gt; ();  

However, if you want to be secure in the future and are not dependent on the assumptions based on the implementation of current NHBnet, then I To accept Rhea, I will write an extension rule:

  Public Stable List & lt; T & gt; ToList & lt; T & gt; (This Identity Criterion) {Return Benchmarking & lt ; T & gt; () .ToList ();}  

Comments