mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-04 07:20:51 +08:00
Updated Repository Layer (markdown)
@@ -124,15 +124,15 @@ Dictionary<string, object[]> CompareState(TEntity newdata);
|
||||
Suppose we have two entities: `User` and `Topic`, and two repositories are defined in the domain class:
|
||||
|
||||
```csharp
|
||||
var userRepository = fsql.GetGuidRepository<User>();
|
||||
var topicRepository = fsql.GetGuidRepository<Topic>();
|
||||
var userRepository = fsql.GetRepository<User>();
|
||||
var topicRepository = fsql.GetRepository<Topic>();
|
||||
```
|
||||
|
||||
In practice, we always worry about the data security of `topicRepository`, that is, it is possible to query or change the topic of other users. Therefore, we have made improvements in the v0.0.7 version, adding the filter lambda expression parameter.
|
||||
|
||||
```csharp
|
||||
var userRepository = fsql.GetGuidRepository<User>(a => a.Id == 1);
|
||||
var topicRepository = fsql.GetGuidRepository<Topic>(a => a.UserId == 1);
|
||||
var userRepository = fsql.GetRepository<User>(a => a.Id == 1);
|
||||
var topicRepository = fsql.GetRepository<Topic>(a => a.UserId == 1);
|
||||
```
|
||||
|
||||
* Attach this condition when querying/modifying/deleting, so that the data of other users will not be modified.
|
||||
|
||||
Reference in New Issue
Block a user