我有两张桌子 -
1. Account
2. Users
Run Code Online (Sandbox Code Playgroud)
在Account表中,DefaultExpensePartner并AccountOwner有外键UserId的字段Users的表.我已经定义了类如下.
public class Account
{
public int AccountId { get; set; }
public string AccountName { get; set; }
public int? AccountOwnerId { get; set; }
public int? DefaultExpensePartnerId { get; set; }
public virtual Users AccountOwner { get; set; }
public virtual Users DefaultExpensePartner { get; set; }
}
public class AccountConfiguration : EntityTypeConfiguration<Account>
{
public AccountConfiguration()
{
this.ToTable("Account");
this.HasKey(c => c.AccountId);
this.Property(c …Run Code Online (Sandbox Code Playgroud) 我想使用格式保留加密将数字加密/解密为具有相同长度的字符串(只有数字和/或大写字母).但我没有找到实施步骤.那么,任何人都可以为C#2.0提供WORKING样本吗?
举个例子,
如果我加密固定长度的明文,如99991232(有或没有固定密钥),那么密码应该像23220978或ED0FTS.如果加密字符串的长度小于纯文本,那么它也可以.但密文长度不得大于纯文本,密文必须具有固定长度.
在我的 DDD 模式中,我将 SqlConnection 只读属性公开给我的 DAL 类对象。但是由于 SqlConnection 是引用类型,我仍然可以调用 .Dispose() 方法,即使它是只读的。
同样的事情发生在 List<> 上,我通过将其转换为 ReadOnlyCollection 来解决,但我碰巧使用许多其他核心 .NET 引用类型对象作为只读属性,并且无法创建包装类。
任何决议?
添加代码:
public class DbContext
{
public SqlConnection sqlConnection {get; private set; }
}
public class caller
{
public caller()
{
var dbContext = new DbContext();
dbContext.sqlConnection.Dispose(); // Want to hide Dispose() method
}
}
Run Code Online (Sandbox Code Playgroud)