We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using System; using System.Threading.Tasks; using FreeSql; using FreeSql.DataAnnotations;
namespace ConsoleApp1 { class Program { static void Main(string[] args) { var freeSqlBuilder = new FreeSqlBuilder() .UseConnectionString(DataType.Sqlite, "Data Source =| DataDirectory |\admindb.db; Pooling = true; Min Pool Size = 1", typeof(FreeSql.Sqlite.SqliteProvider<>)) .UseAutoSyncStructure(false) .UseLazyLoading(false) .UseNoneCommandParameter(true);
var fsql = freeSqlBuilder.Build(); fsql.GlobalFilter.Apply<IOrganization>("Organization", a => fsql.Select<UserOrganization>().Where(b=>b.UserId==1&&b.OrganizationId==a.OrganizationId).Any()); Console.WriteLine(fsql.Select<UserEntity>().ToSql()); Console.WriteLine(); } public interface IOrganization { long OrganizationId { get; set; } } public class UserOrganization: IOrganization { public long UserId { get; set; } public long OrganizationId { get; set; } } /// <summary> /// 用户 /// </summary> [Table(Name = "ad_user")] public class UserEntity :IOrganization { /// <summary> /// 主键Id /// </summary> [Column(Position = 1, IsIdentity = true, IsPrimary = true)] public virtual long Id { get; set; } /// <summary> /// 账号 /// </summary> [Column(StringLength = 60)] public string UserName { get; set; } /// <summary> /// 密码 /// </summary> [Column(StringLength = 60)] public string Password { get; set; } public long OrganizationId { get; set; } } }
}
The text was updated successfully, but these errors were encountered:
原因:
UserOrganization : IOrganization 这个关系导致的死循环,过滤器子层,又会去做过滤,过滤条件又是 UserOrganization,然后一直向下循环做过滤条件。
解决:
在过滤器条件中的子查询中,临时禁用过滤器,如下:
fsql.GlobalFilter.Apply<IOrganization>("Organization", a => fsql.Select<UserOrganization>() .DisableGlobalFilter("Organization") .Where(b => b.UserId == 1 && b.OrganizationId == a.OrganizationId).Any() );
Sorry, something went wrong.
No branches or pull requests
using System;
using System.Threading.Tasks;
using FreeSql;
using FreeSql.DataAnnotations;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var freeSqlBuilder = new FreeSqlBuilder()
.UseConnectionString(DataType.Sqlite, "Data Source =| DataDirectory |\admindb.db; Pooling = true; Min Pool Size = 1", typeof(FreeSql.Sqlite.SqliteProvider<>))
.UseAutoSyncStructure(false)
.UseLazyLoading(false)
.UseNoneCommandParameter(true);
}
The text was updated successfully, but these errors were encountered: