Created
May 8, 2011 17:30
-
-
Save alecwhittington/961524 to your computer and use it in GitHub Desktop.
Sample Implementation of NHQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace QueryTest.Domain.Contracts.Queries | |
{ | |
using SharpArch.Domain.PersistenceSupport; | |
public interface ISampleQuery : IQuery<Address> { } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace QueryTest.Domain.Contracts.Tasks | |
{ | |
using System.Collections.Generic; | |
public interface ISampleTask | |
{ | |
IList<Address> GetAddressForSample(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace QueryTest.Infrastructure.Queries | |
{ | |
using System.Collections.Generic; | |
using System.Linq; | |
using NHibernate.Linq; | |
using QueryTest.Domain; | |
using QueryTest.Domain.Contracts.Queries; | |
using SharpArch.NHibernate; | |
public class SampleQuery : NHQuery<Address>, ISampleQuery | |
{ | |
#region Overrides of NHQuery<Address> | |
public override IList<Address> ExecuteQuery() | |
{ | |
return (from a in Session.Query<Address>() | |
where a.City == "Mesa" | |
select a).ToList(); | |
} | |
#endregion | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace QueryTest.Tasks | |
{ | |
using System.Collections.Generic; | |
using QueryTest.Domain; | |
using QueryTest.Domain.Contracts.Queries; | |
using QueryTest.Domain.Contracts.Tasks; | |
using SharpArch.Domain.PersistenceSupport; | |
public class SampleTask : ISampleTask | |
{ | |
private readonly IRepository<Address> addressRepository; | |
private readonly ISampleQuery sampleQuery; | |
public SampleTask(IRepository<Address> addressRepository, ISampleQuery sampleQuery) | |
{ | |
this.addressRepository = addressRepository; | |
this.sampleQuery = sampleQuery; | |
} | |
#region Implementation of ISampleService | |
public IList<Address> GetAddressForSample() | |
{ | |
return this.addressRepository.PerformQuery(this.sampleQuery); | |
} | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment