mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 增加 EfCoreFluentApi 扩展包,接近 efcore fluentApi 的使用习惯;#4
- 增加 ColumnAttribute 属性 InsertValueSql,插入数据的时候指定用 sql 值;
This commit is contained in:
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using FreeSql.DataAnnotations;
|
||||
|
||||
namespace FreeSql.Extensions.EfCoreFluentApi
|
||||
{
|
||||
public class EfCoreColumnFluent
|
||||
{
|
||||
ColumnFluent _cf;
|
||||
|
||||
internal EfCoreColumnFluent(ColumnFluent tf)
|
||||
{
|
||||
_cf = tf;
|
||||
}
|
||||
|
||||
public ColumnFluent Help() => _cf;
|
||||
|
||||
public EfCoreColumnFluent HasColumnName(string name)
|
||||
{
|
||||
_cf.Name(name);
|
||||
return this;
|
||||
}
|
||||
public EfCoreColumnFluent HashColumnType(string dbtype)
|
||||
{
|
||||
_cf.DbType(dbtype);
|
||||
return this;
|
||||
}
|
||||
public EfCoreColumnFluent IsRequired()
|
||||
{
|
||||
_cf.IsNullable(false);
|
||||
return this;
|
||||
}
|
||||
public EfCoreColumnFluent HasMaxLength(int length)
|
||||
{
|
||||
_cf.StringLength(length);
|
||||
return this;
|
||||
}
|
||||
public EfCoreColumnFluent HasDefaultValueSql(string sqlValue)
|
||||
{
|
||||
_cf.InsertValueSql(sqlValue);
|
||||
return this;
|
||||
}
|
||||
public EfCoreColumnFluent IsRowVersion()
|
||||
{
|
||||
_cf.IsVersion(true);
|
||||
return this;
|
||||
}
|
||||
//public EfCoreColumnFluent HasConversion(Func<object, string> stringify, Func<string, object> parse)
|
||||
//{
|
||||
// return this;
|
||||
//}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user