是否可以使用F#中的LINQ以及如何使用?(Is it possible to use LINQ from F# and how? [duplicate])
这个问题在这里已有答案:
为了访问某些SharePoint数据,我使用了Microsoft.SharePoint.Client库,该库公开了以下API。 C#( link )中有一些示例用法,其中包含以下代码段:
ClientContext context = new ClientContext("http://SiteUrl"); Web web = context.Web; context.Load(web.Lists, lists => lists.Include(list => list.Title, // For each list, retrieve Title and Id. list => list.Id));
Load方法的签名是( 链接 )
public void Load<T>( T clientObject, params Expression<Func<T, Object>>[] retrievals ) where T : ClientObject
Fsharp编译器期望第二个参数类型
Linq.Expressions.Expression<Func<'a,obj>>
要么
Linq.Expressions.Expression<Func<'a,obj>> []
我可以使用F#的
Load
方法吗?这里有一个相关的答案,但我不能将给定代码示例解决方案转换为上面的c#示例。 也许有人可以帮忙吗? 涉及的类型是
list : ListCollection
和list : List
This question already has an answer here:
In order to access some SharePoint data I use the Microsoft.SharePoint.Client Library which exposes the following api. There are example usage in C# (link) from which is the following snippet:
ClientContext context = new ClientContext("http://SiteUrl"); Web web = context.Web; context.Load(web.Lists, lists => lists.Include(list => list.Title, // For each list, retrieve Title and Id. list => list.Id));
The Signature of the Load method is (link)
public void Load<T>( T clientObject, params Expression<Func<T, Object>>[] retrievals ) where T : ClientObject
Fsharp Compiler expect the second paramater to be of type
Linq.Expressions.Expression<Func<'a,obj>>
or
Linq.Expressions.Expression<Func<'a,obj>> []
Can I use the
Load
Method from F# and how ?There is a related answer here but I cant translate the give code example solution to the above c# example. Maybe one can help? The types involved are
list : ListCollection
andlist : List
原文:https://stackoverflow.com/questions/38198613
最满意答案
在c.py的顶层(即任何函数或类之外),您应该能够通过运行获得所需的信息
import traceback
然后检查traceback.extract_stack()的结果。 在运行顶级代码时,模块的导入程序(及其导入程序等递归地)都在callstack上。
In the top-level of c.py (i.e. outside of any function or class), you should be able to get the information you need by running
import traceback
and then examining the result of traceback.extract_stack(). At the time that top-level code is run, the importer of the module (and its importer, etc. recursively) are all on the callstack.
相关问答
更多-
LINUX 如何查看JPG文件[2022-06-13]
find -
使用regexp javascript从源文件中找到所有导入的文件名(find all imported file names from a source file with regexp javascript)[2023-05-25]
您的问题的复杂解决方案(+演示): function run() { var re = /(?:@import)\s+([^;]+)/igm, str = document.getElementById('demo').value, arr = []; while (result = re.exec(str)) { arr = arr.concat(result[1].split(/[,\s]+/)) } //consol ... -
如何调试我自己的DLL文件作为插件导入到其他应用程序?(How to debug my own DLL file that is imported to other application as a plugin?)[2024-02-10]
它可能或可能不起作用,但您可以附加到正在运行的进程 : It might or might not work, but you can attach to a running process: -
使用列表中的第一个元素作为IMPORTED_LOCATION属性,使用其他元素作为INTERFACE_LINK_LIBRARIES属性: find_package(MPI REQUIRED) add_library(MPI SHARED IMPORTED) set_property(TARGET MPI PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${MPI_INCLUDE_PATH}) # Copy list for prevent its from modificati ...
-
怎么样: data.py : class templateElement(object): # all the class stuff here def somefunction(): from element import element # needs element.py's element object 意思是,等到你必须使用它。 这样加载data.py不会导致循环导入。 How about: data.py: class templateElement(object): ...
-
如何从从.xls文件导入的dataGridView获取值(How to get value from dataGridView which is imported from .xls file)[2022-05-12]
我启发了你的答案。 所以,这是我的决议: For data As Integer = 0 To InvestorGridView.Rows.Count - 1 Response.Write(InvestorGridView.Rows(data).Cells(0).Text) Response.Write(InvestorGridView.Rows(data).Cells(1).Text) Response.Write(InvestorGridView.Rows(data).Cells(2 ... -
如何在导入的文件中找到作为导入程序的文件的名称?(How do I find the name of the file that is the importer, within the imported file?)[2023-09-24]
在c.py的顶层(即任何函数或类之外),您应该能够通过运行获得所需的信息 import traceback 然后检查traceback.extract_stack()的结果。 在运行顶级代码时,模块的导入程序(及其导入程序等递归地)都在callstack上。 In the top-level of c.py (i.e. outside of any function or class), you should be able to get the information you need by runni ... -
桥接头文件无法找到导入的Objective-C项目(Bridging Header File can't find an imported Objective-C project)[2024-03-14]
您应该尝试使用'cocoapods'安装库 手动导入项目时可能出现问题。 这是一个关于如何在您的应用程序中安装Cocospods并初始化podfile的教程。 然后,您可以在pod 'SCRecorder'添加pod 'SCRecorder'并返回终端并键入pod install 。 这将安装SCRecorder的所有依赖库。 最后,去尝试运行构建。 它应该工作。 安全方面,保留此构建的备份。 祝你好运 :) OK. I figured it out. I just didn't use the *.xcw ... -
在这种情况下,来自{ base }的两个函数dirname和file.path可能会有所帮助。 > file_user <- file.choose() > file_user [1] "C:\\Users\\ohyeah\\Desktop\\chinese.txt" > path_user <- dirname(file_user) &t; path_user [1] "C:/Users/ohyeahg/Desktop" > newfilename <- "myresult.csv" > newfilep ...
-
从导入的文件自动导入(Automatic imports from imported file)[2022-07-15]
来自__future__ 的进口不是真正的进口! 它们是一种恰好具有类似语法的不同类型的语句 。 文件清楚地说明: 它允许在功能成为标准版本之前,在每个模块的基础上使用新功能。 它们是一种告诉python以不同方式处理该文件的方法,特别是使用可能不同的语法或语义来编译代码。 所以,不,你不能“再出口” __future__进口。 Imports from __future__ are not real imports! They are a different kind of statement that ...