Improve library load performance
This commit is contained in:
parent
2d6120f0c4
commit
1417a4b992
@ -222,7 +222,7 @@ namespace ApplicationServices
|
|||||||
{
|
{
|
||||||
int qtyChanged = await Task.Run(() => SaveContext(context));
|
int qtyChanged = await Task.Run(() => SaveContext(context));
|
||||||
if (qtyChanged > 0)
|
if (qtyChanged > 0)
|
||||||
await Task.Run(finalizeLibrarySizeChange);
|
await Task.Run(() => finalizeLibrarySizeChange(context));
|
||||||
return qtyChanged;
|
return qtyChanged;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -329,7 +329,7 @@ namespace ApplicationServices
|
|||||||
|
|
||||||
// this is any changes at all to the database, not just new books
|
// this is any changes at all to the database, not just new books
|
||||||
if (qtyChanges > 0)
|
if (qtyChanges > 0)
|
||||||
await Task.Run(() => finalizeLibrarySizeChange());
|
await Task.Run(() => finalizeLibrarySizeChange(context));
|
||||||
logTime("importIntoDbAsync -- post finalizeLibrarySizeChange");
|
logTime("importIntoDbAsync -- post finalizeLibrarySizeChange");
|
||||||
|
|
||||||
return newCount;
|
return newCount;
|
||||||
@ -378,7 +378,7 @@ namespace ApplicationServices
|
|||||||
|
|
||||||
var qtyChanges = context.SaveChanges();
|
var qtyChanges = context.SaveChanges();
|
||||||
if (qtyChanges > 0)
|
if (qtyChanges > 0)
|
||||||
finalizeLibrarySizeChange();
|
finalizeLibrarySizeChange(context);
|
||||||
|
|
||||||
return qtyChanges;
|
return qtyChanges;
|
||||||
}
|
}
|
||||||
@ -407,7 +407,7 @@ namespace ApplicationServices
|
|||||||
|
|
||||||
var qtyChanges = context.SaveChanges();
|
var qtyChanges = context.SaveChanges();
|
||||||
if (qtyChanges > 0)
|
if (qtyChanges > 0)
|
||||||
finalizeLibrarySizeChange();
|
finalizeLibrarySizeChange(context);
|
||||||
|
|
||||||
return qtyChanges;
|
return qtyChanges;
|
||||||
}
|
}
|
||||||
@ -432,7 +432,7 @@ namespace ApplicationServices
|
|||||||
|
|
||||||
var qtyChanges = context.SaveChanges();
|
var qtyChanges = context.SaveChanges();
|
||||||
if (qtyChanges > 0)
|
if (qtyChanges > 0)
|
||||||
finalizeLibrarySizeChange();
|
finalizeLibrarySizeChange(context);
|
||||||
|
|
||||||
return qtyChanges;
|
return qtyChanges;
|
||||||
}
|
}
|
||||||
@ -445,9 +445,9 @@ namespace ApplicationServices
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// call this whenever books are added or removed from library
|
// call this whenever books are added or removed from library
|
||||||
private static void finalizeLibrarySizeChange()
|
private static void finalizeLibrarySizeChange(LibationContext context)
|
||||||
{
|
{
|
||||||
var library = DbContexts.GetLibrary_Flat_NoTracking(includeParents: true);
|
var library = context.GetLibrary_Flat_NoTracking(includeParents: true);
|
||||||
LibrarySizeChanged?.Invoke(null, library);
|
LibrarySizeChanged?.Invoke(null, library);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ namespace DataLayer
|
|||||||
public class LibationContextFactory : DesignTimeDbContextFactoryBase<LibationContext>
|
public class LibationContextFactory : DesignTimeDbContextFactoryBase<LibationContext>
|
||||||
{
|
{
|
||||||
protected override LibationContext CreateNewInstance(DbContextOptions<LibationContext> options) => new LibationContext(options);
|
protected override LibationContext CreateNewInstance(DbContextOptions<LibationContext> options) => new LibationContext(options);
|
||||||
protected override void UseDatabaseEngine(DbContextOptionsBuilder optionsBuilder, string connectionString) => optionsBuilder.UseSqlite(connectionString);
|
protected override void UseDatabaseEngine(DbContextOptionsBuilder optionsBuilder, string connectionString)
|
||||||
|
=> optionsBuilder.UseSqlite(connectionString, ob => ob.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user