Created
January 24, 2011 23:43
-
-
Save fboiton/794223 to your computer and use it in GitHub Desktop.
simple DAO with Entlib DAAB
This file contains hidden or 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
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