Skip to content

How do I loop through all tables to set query filter automatically? #3062

Closed Answered by sdanyliv
ww9 asked this question in Q&A
Discussion options

You must be logged in to vote

Try this sample. It registers all entities which are part of MyDb class. For sure constructor should be corrected for your needs.

public partial class MyDb : LinqToDB.Data.DataConnection
{
    public long currentTenantId;

    public MyDb()
    {
        AddMappingSchema(InitializedMappingSchema);
    }

    private static MethodInfo RegisterTenantMethodInfo =
        MemberHelper.MethodOfGeneric(() => RegisterTenant<int>(null));

    private static MappingSchema InitializedMappingSchema = InitMappingSchema();

    public static MappingSchema InitMappingSchema()
    {
        var ms      = new MappingSchema();
        var builder = ms.GetFluentMappingBuilder();

        var props = typeof(M…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by MaceWindu
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #3052 on June 22, 2021 17:11.