Skip to content

Commit 0a07733

Browse files
committed
nuget updates
1 parent 80e9aba commit 0a07733

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

src/EFCore.PostgresExtensions/Extensions/QueryableExtensions.cs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace EFCore.PostgresExtensions.Extensions
66
public static class QueryableExtensions
77
{
88
internal const string ForUpdateKey = "for update ";
9+
910
/// <summary>
1011
/// Use this method for selecting data with locking.
1112
/// <para>Attention! Be aware that this method works only inside the transaction scope(dbContext.BeginTransaction) and you need to register it in startup.</para>
@@ -14,11 +15,53 @@ public static class QueryableExtensions
1415
/// <param name="query">Query to lock.</param>
1516
/// <param name="lockBehavior">Behavior organizes the way data should be locked, for more information check enum values.</param>
1617
/// <returns>The same query with locking behavior added.</returns>
17-
public static IQueryable<T> ForUpdate<T>(this IQueryable<T> query, LockBehavior lockBehavior = LockBehavior.Default)
18+
public static IQueryable<T> ForUpdate<T>(this IQueryable<T> query,
19+
LockBehavior lockBehavior = LockBehavior.Default)
1820
{
1921
query = query.TagWith(ForUpdateKey + lockBehavior.GetSqlKeyword());
2022

2123
return query.AsQueryable();
2224
}
25+
26+
27+
// public static Task<T> FirstOrDefaultByBytesAsync<T>(
28+
// this IQueryable<T> query,
29+
// Expression<Func<T, byte[]>> byteArrayProperty,
30+
// byte[] searchBytes,
31+
// int numberOfBytes,
32+
// CancellationToken cancellationToken = default) where T : class
33+
// {
34+
// if (searchBytes == null || searchBytes.Length < numberOfBytes)
35+
// {
36+
// throw new ArgumentException($"Input array must be at least {numberOfBytes} bytes long.");
37+
// }
38+
//
39+
// var firstBytes = searchBytes.Take(numberOfBytes).ToArray();
40+
//
41+
// // Retrieve the DbContext from the IQueryable
42+
// var context = query.GetDbContext();
43+
//
44+
// // Get the table name from the DbContext model
45+
// var entityType = context.Model.FindEntityType(typeof(T));
46+
// var tableName = entityType.GetTableName();
47+
//
48+
// // Construct the SQL query
49+
// var queryText = $@"
50+
// SELECT * FROM ""{tableName}""
51+
// WHERE SUBSTRING(""Data"" FROM 1 FOR {numberOfBytes}) = @p0
52+
// LIMIT 1";
53+
//
54+
// // Apply the byte array comparison using FromSqlRaw
55+
// return query.FromSql(queryText, firstBytes).FirstOrDefaultAsync(cancellationToken);
56+
// }
57+
//
58+
// private static DbContext GetDbContext<T>(this IQueryable<T> query) where T : class
59+
// {
60+
// var infrastructure = (IInfrastructure<IServiceProvider>)query;
61+
// var serviceProvider = infrastructure.Instance;
62+
// var currentContext = serviceProvider.GetService(typeof(ICurrentDbContext)) as ICurrentDbContext;
63+
// return currentContext!.Context;
64+
// }
65+
// }
2366
}
24-
}
67+
}

test/PandaNuGet.Demo/PandaNuGet.Demo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<ItemGroup>
1111
<PackageReference Include="Dapper" Version="2.1.35" />
1212
<PackageReference Include="EFCore.BulkExtensions.PostgreSql" Version="8.0.4" />
13-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.5" />
13+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6" />
1414
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
1515
</ItemGroup>
1616

0 commit comments

Comments
 (0)