Martin, just a hint, when you post code use our "Code" button. It's the last toolbar button on the right when editing a post, I'll re-post your code (modified though) then comment.
Code:
public override IDataReader GetAffiliate(int AffiliateId, int VendorId, int PortalID)
{
AffiliatesQuery a = new AffiliatesQuery("a");
VendorsQuery v = new VendorsQuery("v");
a.Select(a.AffiliateId,
a.VendorId,
a.StartDate,
a.EndDate,
a.Clicks,
a.Cpc,
a.Cpa,
a.Acquisitions);
a.InnerJoin(v).On(v.VendorId == a.VendorId);
a.Where(a.AffiliateId == AffiliateId & a.VendorId == VendorId);
AffiliatesCollection collection = new AffiliatesCollection();
coll.Load(a); // JUST LOAD IT LIKE THIS
}
Notice how I created an AffiliatesCollection and just called load on it passing in the query. That's It !!
Now, assume that you have the same database schema in PostgreSQL, Oracle, and SQL (as do our unit tests). Assume your default connection is SQL, the code above would work perfectly. However, if somebody wanted to run your code on Oracle all they would have to do is change the default connection in the config to Oracle, no changes in your code, the same physical binary would work. There is no reason to yank the raw sql out, however, you can see if it you want to like this after you call load:
string lastQuery = coll.Query.es.LastQuery;
Feel free to follow up ...
EntitySpaces |
Twitter |
BLOG | Please honor our Software License