Giter Site home page Giter Site logo

Comments (1)

luoyunchong avatar luoyunchong commented on July 21, 2024

使用方式和微软EFCore应该差不多 https://learn.microsoft.com/zh-cn/aspnet/core/security/data-protection/implementation/key-storage-providers?view=aspnetcore-7.0&tabs=visual-studio#entity-framework-core

1.FreeSql单例注册等

        IFreeSql fsql = new FreeSqlBuilder()
                 .UseConnectionString(....)
                 .UseAutoSyncStructure(true)
                 .UseNameConvert(NameConvertType.PascalCaseToUnderscoreWithLower)
                 .UseGenerateCommandParameterWithLambda(true)//默认false,针对 lambda 表达式解析,设置成true时方便查看SQL
                 .UseNoneCommandParameter(true) //默认true,针对insert/update/delete是否参数化
                 .UseMonitorCommand(
                     cmd => Trace.WriteLine("\r\n线程" + Thread.CurrentThread.ManagedThreadId + ": " + cmd.CommandText)
               ).Build();

        services.AddSingleton(fsql);
        services.AddFreeKitCore();

        services.AddFreeDbContext<DataProtectionKeyContext>(options =>
                 options.UseFreeSql(fsql).UseOptions(
                     new DbContextOptions()
                     {
                         EnableCascadeSave = true
                     })
             );

2 定义DbContext

public class DataProtectionKeyContext : DbContext, IDataProtectionKeyContext
{
    public DataProtectionKeyContext(IFreeSql fsql, DbContextOptions options) : base(fsql, options) { }

    public DbSet<DataProtectionKey> DataProtectionKeys { get; set; }
}
    // using Microsoft.AspNetCore.DataProtection;
    services.AddDataProtection()
        .PersistKeysToDbContext<DataProtectionKeyContext>();

3.Dataprotection具体方法使用,直接看官方文档,我也没用过,只是写了下单元测试

public string DataProtect(string input)

from freekit.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.