首页 \ 问答 \ 如何转换ASP.NET会话以取回列表?(How do I cast a ASP.NET session to get back my list?)

如何转换ASP.NET会话以取回列表?(How do I cast a ASP.NET session to get back my list?)

背景:我有两个网页,一个是事物列表,另一个是事物的细节。 在列表中,用户可以进行筛选和排序,从而生成排序列表。 在细节上,我希望用户具有Next和Previous导航。

我正在使用带有Razor的ASP.Net网页,使用WebMatrix或Visual Studio进行编辑。 列表页面上的代码很简单。 RefID是一个整数Key唯一标识记录:

var db = Database.Open("dbname");
...
var q = db.Query( sqlthatworks , passInVarables);
Session["WorkingList"] = q.Select( x => new { x.RefID } );

在详细信息页面上,我需要能够访问Session [“WorkingList”],以便我可以使用此StackOverFLow问题提供的Linq来查找下一个和之前的记录 ,这些记录将类似于:

var workingList = (IEnumerable<dynamic>) Session["WorkingList"];
var nextRecord = workingList.SkipWhile(i => i.RefID != currentRecord).Skip(1).First();

我知道db.Query返回一个IEnumerable <Object> ,但我猜测真正回归的是IEnumerable <dynamic>。 这有效,但似乎过于复杂。 有没有更好的办法?


Background: I have two web pages, one is a list of things, and the other is the detail of the thing. On the list, the user can filter and sort, which results in a sorted list. On the details, I would like the user to have Next and Previous navigation.

I'm using ASP.Net Web Pages with Razor, edited with either WebMatrix or Visual Studio. The code on the list page is simple. The RefID is an integer Key uniquely identify the record:

var db = Database.Open("dbname");
...
var q = db.Query( sqlthatworks , passInVarables);
Session["WorkingList"] = q.Select( x => new { x.RefID } );

On the details page, I need to be able to access the Session["WorkingList"] such that I can use the Linq provided by this StackOverFLow question to find the next and previous records, which will be something like:

var workingList = (IEnumerable<dynamic>) Session["WorkingList"];
var nextRecord = workingList.SkipWhile(i => i.RefID != currentRecord).Skip(1).First();

I know that db.Query returns a IEnumerable< Object>, but I'm guessing what's really coming back is a IEnumerable< dynamic >. And that works, but seems overly complicated. Is there a better way?


原文:https://stackoverflow.com/questions/8490435
更新时间:2023-07-31 15:07

最满意答案

截图应该保存在桌面上。


The screenshot should be saved on the Desktop.

相关问答

更多
  • 在问我问题六分钟后,我想出了答案。 当鼠标悬停在“截图”按钮上时,会弹出一个提示框。 屏幕截图会直接保存到桌面,您将看到它们以文件名格式“ Screen Shot YYYY-MM-DD at HH.mm.ss AM/PM.png ”保存。 Six minutes after asking my question I figured out the answer. There's a tooltip that pops up when hovering over the "Take Screenshot" b ...
  • 截图应该保存在桌面上。 The screenshot should be saved on the Desktop.
  • 在您的项目构建设置下 选择部署部分 将iOS部署目标更改为iOS 5.0或更低版本 现在您可以继续将部署目标从设备更改为模拟器! 在我的情况下,部署目标设置为5.1版,我仍然在运行雪leapord操作系统,并从xcode 4.3复制适当的JARS,使其运行于运行iOS 5.1的设备。 但是,我的模拟器还没有支持5.1版本,所以我将部署目标更改为较低版本,例如5.0或4.2,它不会让我在模拟器上运行。 Under Your project Build Settings select Deployment se ...
  • 有时候我会使用一个相当丑陋的黑客来做到这一点。 当您在模拟位置时将设备连接到Xcode时,只需移除照明电缆而不直接杀死应用程序。 该应用程序将崩溃,但当您重新启动它时,您将看到它显示相同的模拟位置,尽管它不再连接到Xcode。 请注意,这不是一种优雅的方法 ,为了使您的设备位置服务再次正常工作,您必须在设备上运行Xcode中的应用并明确设置Debug/Simulate Location/Don't Simulate Location Sometimes I use a quite ugly hack to ...
  • 它只是说“iPhone”,因为你的iPhone的名字是“iPhone”。 所以你的iPhone在设备列表中,我认为你可以正常构建和运行应用程序。 检查iPhone的设置以确保设备名称。 It just says "iPhone" because name of your iPhone is "iPhone". So your iPhone is in list of devices, I think you can build and run the application as normal. Check ...
  • 附加实际设备进行调试时: 该设备将继承调试>模拟位置下的位置调试设置。 如果将此设置为“不模拟位置”,则附加设备将使用GPS / WiFi(如果设备有能力)返回的实际位置。 如果您选择任何其他设置(位置),则连接的设备将不会使用它的真实位置,而会模拟所选的位置。 如果您在产品>架构>编辑架构下禁用核心位置“允许位置模拟”,您将无法模拟首次亮相的位置,但是如果连接的设备支持位置,则将使用真实的设备位置。 When you attach a real device for debugging: The devi ...
  • 确保在启用调试标志的情况下构建应用程序。 该文件应位于您的库文件夹中: ~/Library/Developer/Xcode/DerivedData//Build/Products/Debug-iphoneos 在此文件夹中,将有一个.dSYM包文件夹,其中包含Contents/Resources/中的符号文件。 您还可以通过在二进制文件/库上运行dsymutil来生成.dSYM软件包文件。 Ensure that your application is built ...
  • 在xcode 4中设置不需要此设置,因为它会自动设置位置。 来自这个论坛帖子 : 您不再需要在Xcode 4中执行此操作; 它自动将构建产品与〜/ Library / Developer / Xcode / DerivedData中的每个工作区隔离开来。 相反,您需要使用适当的项目作为成员(以及您的其他应用程序/框架目标)创建工作区。 如果您查看其中一个iOS示例应用程序,您应该能够打开它并构建(因为那些已经有框架的项目引用,Xcode 4跟随示例)。 查看此doc以获取特定的项目/工作区构建设置: htt ...
  • 我想到了。 它涉及将屏幕截图保存为UIImage,然后使用此处的非常有用的教程让我进行PDF转换。 事实证明,有一些功能可以处理Core Graphics类中PDF文档的制作。 I figured it out. It involved saving a screenshot as a UIImage, and then using the very helpful tutorial found here to get me going with the PDF conversion. As it turn ...
  • 我只是尝试重启XCode并多次运行/停止应用程序,然后复选框神奇地出现了。 无论如何,我还向Apple发射了雷达。 I just tried restarting XCode and running/stopping the app several times, then the checkbox magically appeared. I've also fired a radar to Apple anyway.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)