Skip to content

Instantly share code, notes, and snippets.

@FransBouma
Created May 14, 2013 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FransBouma/5576427 to your computer and use it in GitHub Desktop.
Save FransBouma/5576427 to your computer and use it in GitHub Desktop.
First LLBLGen Pro v4.0 async api results. :)
public static string ConnectionString = @"data source=zeusVM\SQLSERVER2005;initial catalog=AdventureWorks;integrated security=SSPI;persist security info=False;packet size=4096";
static void Main(string[] args)
{
Console.WriteLine("Starting");
FetchEntityCollectionAsync();
Console.WriteLine("Fetch called. Press enter to quit");
Console.ReadLine();
}
private static async Task FetchEntityCollectionAsync()
{
int localId = 0;
var task1 = FetchSalesOrderHeaderEntitiesAsync(localId++);
var task2 = FetchSalesOrderHeaderEntitiesAsync(localId++);
var task3 = FetchSalesOrderHeaderEntitiesAsync(localId++);
var task4 = FetchSalesOrderHeaderEntitiesAsync(localId++);
var task5 = FetchSalesOrderHeaderEntitiesAsync(localId++);
var task6 = FetchSalesOrderHeaderEntitiesAsync(localId++);
var task7 = FetchSalesOrderHeaderEntitiesAsync(localId++);
await Task.WhenAll(task1, task2, task3, task4, task5, task6, task7);
}
public static async Task FetchSalesOrderHeaderEntitiesAsync(int localId)
{
Console.WriteLine("Entering async fetch collection method. LocalID {0}", localId);
var qf = new QueryFactory();
var q = qf.SalesOrderHeader;
var sw = new Stopwatch();
sw.Start();
var headers = new EntityCollection<SalesOrderHeaderEntity>();
using(var adapter = new DataAccessAdapter())
{
await adapter.FetchQueryAsync(q, headers, CancellationToken.None);
}
sw.Stop();
Console.WriteLine("Fetched {0} LLBLGen Pro v4 entities from the DB. Took {1}ms. LocalID {2}", headers.Count, sw.ElapsedMilliseconds, localId);
}
Starting
Entering async fetch collection method. LocalID 0
Entering async fetch collection method. LocalID 1
Entering async fetch collection method. LocalID 2
Entering async fetch collection method. LocalID 3
Entering async fetch collection method. LocalID 4
Entering async fetch collection method. LocalID 5
Entering async fetch collection method. LocalID 6
Fetch called. Press enter to quit
Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 3314ms. LocalID 3
Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 3395ms. LocalID 1
Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 3527ms. LocalID 5
Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 4123ms. LocalID 0
Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 5008ms. LocalID 2
Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 5973ms. LocalID 4
Fetched 31465 LLBLGen Pro v4 entities from the DB. Took 6037ms. LocalID 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment