mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 12:28:15 +08:00
修复 IsIgnore 过滤字段后,查询的错误;
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Version>0.5.1.1</Version>
|
||||
<Version>0.5.1.2</Version>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>YeXiangQin</Authors>
|
||||
<Description>FreeSql is the most convenient ORM in dotnet. It supports Mysql, Postgresql, SqlServer, Oracle and Sqlite.</Description>
|
||||
|
@ -377,6 +377,8 @@ namespace FreeSql.Internal.CommonProvider {
|
||||
var index = 0;
|
||||
var otherindex = 0;
|
||||
foreach (var prop in props.Values) {
|
||||
if (tb.Table.ColumnsByCsIgnore.ContainsKey(prop.Name)) continue;
|
||||
|
||||
if (tb.Table.ColumnsByCs.TryGetValue(prop.Name, out var col)) { //普通字段
|
||||
if (index > 0) field.Append(", ");
|
||||
var quoteName = _commonUtils.QuoteSqlName(col.Attribute.Name);
|
||||
|
@ -11,6 +11,7 @@ namespace FreeSql.Internal.Model {
|
||||
public Dictionary<string, PropertyInfo> Properties { get; set; } = new Dictionary<string, PropertyInfo>(StringComparer.CurrentCultureIgnoreCase);
|
||||
public Dictionary<string, ColumnInfo> Columns { get; set; } = new Dictionary<string, ColumnInfo>(StringComparer.CurrentCultureIgnoreCase);
|
||||
public Dictionary<string, ColumnInfo> ColumnsByCs { get; set; } = new Dictionary<string, ColumnInfo>(StringComparer.CurrentCultureIgnoreCase);
|
||||
public Dictionary<string, ColumnInfo> ColumnsByCsIgnore { get; set; } = new Dictionary<string, ColumnInfo>(StringComparer.CurrentCultureIgnoreCase);
|
||||
public ColumnInfo[] Primarys { get; set; }
|
||||
public string CsName { get; set; }
|
||||
public string DbName { get; set; }
|
||||
|
@ -70,7 +70,6 @@ namespace FreeSql.Internal {
|
||||
IsPrimary = false,
|
||||
IsIgnore = false
|
||||
};
|
||||
if (colattr.IsIgnore) continue;
|
||||
if (string.IsNullOrEmpty(colattr.DbType)) colattr.DbType = tp?.dbtypeFull ?? "varchar(255)";
|
||||
colattr.DbType = colattr.DbType.ToUpper();
|
||||
|
||||
@ -104,6 +103,10 @@ namespace FreeSql.Internal {
|
||||
CsType = p.PropertyType,
|
||||
Attribute = colattr
|
||||
};
|
||||
if (colattr.IsIgnore) {
|
||||
trytb.ColumnsByCsIgnore.Add(p.Name, col);
|
||||
continue;
|
||||
}
|
||||
trytb.Columns.Add(colattr.Name, col);
|
||||
trytb.ColumnsByCs.Add(p.Name, col);
|
||||
}
|
||||
@ -807,6 +810,8 @@ namespace FreeSql.Internal {
|
||||
Expression.Assign(readpknullExp, Expression.Constant(false))
|
||||
});
|
||||
foreach (var ctorParm in ctorParms) {
|
||||
if (typetb.ColumnsByCsIgnore.ContainsKey(ctorParm.Name)) continue;
|
||||
|
||||
var ispkExp = new List<Expression>();
|
||||
Expression readVal = Expression.Assign(readpkvalExp, Expression.Call(rowExp, MethodDataReaderGetValue, dataIndexExp));
|
||||
Expression readExpAssign = null; //加速缓存
|
||||
@ -823,7 +828,7 @@ namespace FreeSql.Internal {
|
||||
|
||||
//判断主键为空,则整个对象不读取
|
||||
//blockExp.Add(Expression.Assign(readpkvalExp, Expression.Call(rowExp, MethodDataReaderGetValue, dataIndexExp)));
|
||||
if (typetb.ColumnsByCs.TryGetValue(ctorParm.Name, out var trycol) && trycol.Attribute.IsPrimary) {
|
||||
if (typetb.ColumnsByCs.TryGetValue(ctorParm.Name, out var trycol) && trycol.Attribute.IsPrimary == true) {
|
||||
ispkExp.Add(
|
||||
Expression.IfThen(
|
||||
Expression.AndAlso(
|
||||
@ -892,6 +897,8 @@ namespace FreeSql.Internal {
|
||||
var props = type.GetProperties();//.ToDictionary(a => a.Name, a => a, StringComparer.CurrentCultureIgnoreCase);
|
||||
var propIndex = 0;
|
||||
foreach (var prop in props) {
|
||||
if (typetb.ColumnsByCsIgnore.ContainsKey(prop.Name)) continue;
|
||||
|
||||
var ispkExp = new List<Expression>();
|
||||
var propGetSetMethod = prop.GetSetMethod();
|
||||
Expression readVal = Expression.Assign(readpkvalExp, Expression.Call(rowExp, MethodDataReaderGetValue, tryidxExp));
|
||||
@ -909,7 +916,7 @@ namespace FreeSql.Internal {
|
||||
|
||||
//判断主键为空,则整个对象不读取
|
||||
//blockExp.Add(Expression.Assign(readpkvalExp, Expression.Call(rowExp, MethodDataReaderGetValue, dataIndexExp)));
|
||||
if (typetb.ColumnsByCs.TryGetValue(prop.Name, out var trycol) && trycol.Attribute.IsPrimary) {
|
||||
if (typetb.ColumnsByCs.TryGetValue(prop.Name, out var trycol) && trycol.Attribute.IsPrimary == true) {
|
||||
ispkExp.Add(
|
||||
Expression.IfThen(
|
||||
Expression.AndAlso(
|
||||
|
Reference in New Issue
Block a user