mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-13 03:40:57 +08:00
update
@@ -18,6 +18,59 @@ FreeSql has made great efforts in querying data, especially the functions such a
|
||||
- [《Sharding Tables and Database》](Sharding-Tables-and-Database)
|
||||
- [《Tenant》](Tenant)
|
||||
|
||||
## SqlServer WithLock、WithIndex
|
||||
|
||||
```csharp
|
||||
var list = fsql.Select<Region>()
|
||||
.WithLock()
|
||||
.Limit(1).ToList();
|
||||
//SELECT TOP 1 ... FROM [Region] a With(NoLock)
|
||||
|
||||
var list = fsql.Select<Region>()
|
||||
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
|
||||
.Limit(1).ToList();
|
||||
//SELECT TOP 1 ... FROM [Region] a With(NoLock, NoWait)
|
||||
|
||||
var list = fsql.Select<Region>()
|
||||
.WithLock()
|
||||
.WithIndex("idx_01")
|
||||
.Limit(1).ToList();
|
||||
//SELECT TOP 1 ... FROM [Region] a With(index=idx_01, NoLock)
|
||||
```
|
||||
|
||||
Multi-Tables Query:
|
||||
|
||||
```csharp
|
||||
var list = Select<Region, T2>()
|
||||
.InnerJoin((a, b) => a.x == b.xx)
|
||||
.WithLock(SqlServerLock.NoLock, new Dictionary<Type, bool>
|
||||
{
|
||||
[typeof(T2)] = false
|
||||
})
|
||||
.WithIndex("idx_01", new Dictionary<Type, string>
|
||||
{
|
||||
[typeof(T2)] = "idx_02"
|
||||
})
|
||||
.Limit(1).ToList();
|
||||
//SELECT TOP 1 ..
|
||||
//FROM [Region] a With(index=idx_01, NoLock)
|
||||
//INNER JOIN [T2] b With(index=idx_02) ON a.[x] = b.[xx]
|
||||
``````
|
||||
|
||||
Global NoLock:
|
||||
|
||||
```csharp
|
||||
//All entities
|
||||
fsql.SetGlobalSelectWithLock(SqlServerLock.NoLock, null);
|
||||
|
||||
//Effective designation
|
||||
fsql.SetGlobalSelectWithLock(SqlServerLock.NoLock, new Dictionary<Type, bool>
|
||||
{
|
||||
[typeof(Region)] = true,
|
||||
[typeof(T2)] = true
|
||||
});
|
||||
```
|
||||
|
||||
## Special introduction to WhereDynamicFilter
|
||||
|
||||
[《高效理解 FreeSql WhereDynamicFilter,深入了解设计初衷》](https://www.cnblogs.com/FreeSql/p/16485310.html)
|
||||
|
||||
Reference in New Issue
Block a user