Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加InsertOrUpdateDict的Dynamic类型扩展方法 #1784

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions FreeSql/Extensions/FreeSqlGlobalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,18 @@ public static InsertOrUpdateDictImpl InsertOrUpdateDict(this IFreeSql freesql, I
insertOrUpdateDict._insertOrUpdateProvider.SetSource(source);
return insertOrUpdateDict;
}
public static InsertOrUpdateDictImpl InsertOrUpdateDict(this IFreeSql freesql, IEnumerable<dynamic> source)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要使用 dynamic ,如果你是用的基类型是 ExpandoObject 那么可以 使用它的基类 IDictionary<string,Object>

{

if (source?.Any() == true)
{
var newSource = source.Select(t => new Dictionary<string, object>(t));
foreach (var dict in newSource) LocalReplaceDictDBNullValue(dict);
}
var insertOrUpdateDict = new InsertOrUpdateDictImpl(freesql);
insertOrUpdateDict._insertOrUpdateProvider.SetSource(source);
return insertOrUpdateDict;
}
/// <summary>
/// 删除数据字典 Dictionary&lt;string, object&gt;
/// </summary>
Expand Down