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

Conversation

hjkl950217
Copy link
Contributor

@hjkl950217 hjkl950217 commented Apr 18, 2024

近期有一个需求,需要从mysql迁移数据到DM, 而且还能能使用多次,还好InsertOrUpdateDict方法解决了我的问题。
Dictionary<string, object>Dynamic理论上能相互转换,我项目里用的多的是Dynamic,背后是ExpandoObject.

顺手就把需要的这个方法扩展出来了

@2881099
Copy link
Collaborator

2881099 commented Apr 18, 2024

感谢贡献,不过由于 dynamic 依赖 Microsoft.xxx.Script 版本会导致依赖冲突

因此默认没有集成这个类型,FreeSql 宗旨是零依赖。

@hjkl950217
Copy link
Contributor Author

是.net框架上的Script版本吗? 我这里是.net6 只引用了FreeSql.Provider.MySql,没有发现你说的这个。
PR里也只是把每个元素,转换成Dictionary<string, object>, 应该木有依赖呀

@2881099
Copy link
Collaborator

2881099 commented Apr 18, 2024

.net framework,还有 xamarin,这个之前已经遇到过,.net6高版本没有这个问题。

@hjkl950217
Copy link
Contributor Author

要不加一个条件编译? net6以上才有这个扩展

@@ -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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants