Skip to content

Instantly share code, notes, and snippets.

@fboiton
Created January 24, 2011 23:43
Show Gist options
  • Save fboiton/794223 to your computer and use it in GitHub Desktop.
Save fboiton/794223 to your computer and use it in GitHub Desktop.
simple DAO with Entlib DAAB
public class ListingsGridDao{
private const string QueryListings = "query with parameters @advertiserId";
private const string QueryReportListings = "query with parameters @advertiserId, @startDate, @endDate";
public IEnumerable<Listing> GetListings(int advertiserId){
var db = DatabaseFactory.CreateDatabase(ConfigurationManager.AppSettings["DBReportsCRUD"]);
List<Listing> result = new List<Listing>();
using(var cmd = db.GetSqlStringCommand(QueryListings)){
db.AddInParameter(cmd, "@advertiserId", DbType.Int,advertiserId );
using(var reader = db.ExecuteReader(cmd)){
while(reader.Read()){
result.Add(
new Listing{
Id = Convert.ToInt32(reader["profile_id"])
}
);
}
if(result.Count()<=0) throw new InvalidOperationException("Listings not loaded... ");
}
}
}
public IEnumerable<ReportListing> GetReportListings(int advertiserId, string startDate, string endDate){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment