WhereCascade multi-table query is very convenient, and with it you can easily complete the type of soft-delete function tenant conditions.
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10")
.Build();
[Table(Name = "tb_topic")]
class Topic {
[Column(IsIdentity = true, IsPrimary = true)]
public int Id { get; set; }
public int Clicks { get; set; }
public int TestTypeInfoGuid { get; set; }
public TestTypeInfo Type { get; set; }
public string Title { get; set; }
public DateTime CreateTime { get; set; }
}
class TestTypeInfo {
public int Guid { get; set; }
public int ParentId { get; set; }
public TestTypeParentInfo Parent { get; set; }
public string Name { get; set; }
public List<Topic> Topics { get; set; }
}
class TestTypeParentInfo {
public int Id { get; set; }
public string Name { get; set; }
}
ISelect<Topic> select => fsql.Select<Topic>();
WhereCascade
Multi-table queries like conditions isdeleted gave each table, very troublesome. After WhereCascade use when generating sql, all the tables attached to this condition.
Such as:
fsql.Select<t1>()
.LeftJoin<t2>(...)
.WhereCascade(x => x.IsDeleted == false)
.ToList();
The resulting SQL:
SELECT ...
FROM t1
LEFT JOIN t2 on ... AND (t2.IsDeleted = 0)
WHERE t1.IsDeleted = 0
Which entities may enter into force only when the additional expression, child support table queries. The more the number of single-table query using the greater the benefits.
Applications can range:
- Sub-queries, one to many, many to many, since the definition of sub-queries;
- Join query, navigation attributes, custom Join query;
- Include / IncludeMany subset of queries;
Does not support [the delay] property of broadcasting;
This filter [] function and the different propagation times for a single multi-table query condition;