using System.Collections.Generic; using EnterpriseSample.Core.DataInterfaces; using EnterpriseSample.Core.Domain; using NHibernate; using ProjectBase.Data; using ProjectBase.Utils; namespace EnterpriseSample.Data { public class HistoricalOrderSummaryDao : IHistoricalOrderSummaryDao { public HistoricalOrderSummaryDao(string sessionFactoryConfigPath) { Check.Require(! string.IsNullOrEmpty(sessionFactoryConfigPath), "sessionFactoryConfigPath may not be null nor empty"); this.sessionFactoryConfigPath = sessionFactoryConfigPath; } public List<HistoricalOrderSummary> GetCustomerOrderHistoryFor(string customerId) { Check.Require(! string.IsNullOrEmpty(customerId), "customerId may not be null or empty"); IQuery query = NHibernateSession.GetNamedQuery("GetCustomerOrderHistory") .SetString("CustomerID", customerId) .SetResultTransformer( new NHibernate.Transform.AliasToBeanConstructorResultTransformer( typeof (HistoricalOrderSummary).GetConstructors()[0])); return query.List<HistoricalOrderSummary>() as List<HistoricalOrderSummary>; } /// <summary> /// Exposes the ISession used within the DAO. /// </summary> private ISession NHibernateSession { get { return NHibernateSessionManager.Instance.GetSessionFrom(sessionFactoryConfigPath); } } protected readonly string sessionFactoryConfigPath; } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)