问题列表 - 第45265页

NHibernate ISession生命周期; 何时可以在每个存储库方法中创建/部署?

我正在使用单级,单用户应用,FluentNHibernate.具有多个线程,由时间触发器和传入套接字消息触发器触发.

哪些要求将决定我是否可以在存储库的每个方法中创建/处置ISession,或者我是否需要在多个调用上维护ISession生命周期,可能是从程序开始到结束?

例如,延迟加载是否需要维护会话?如果我不使用lazyload,为什么我应该保持ISession?

目前我的存储库方法如下所示,但我想知道我做错了..

public class ProductRepository
{
    public void Delete(Product product)
    {
        using (ISession session = FNH_Manager.OpenSession())
        {
            using (ITransaction transaction = session.BeginTransaction())
            {
                session.Delete(product);
                transaction.Commit();
            }
        }
    }

class FNH_Manager
{
    private static Configuration cfg;
    private static ISessionFactory sessionFactory;

    public static void ConfigureSessionFactory()
    {
        sessionFactory = CreateSessionFactory();
    }

    public static ISession OpenSession()
    {
        return sessionFactory.OpenSession();
    }
Run Code Online (Sandbox Code Playgroud)

EDIT1: 尝试处理"每次通话会话":

   public class EmployeeRepository
   {  
        public static void Delete(Employee employee)
        { …
Run Code Online (Sandbox Code Playgroud)

.net c# database nhibernate repository

3
推荐指数
1
解决办法
2297
查看次数

jquery ui accordion - 多种手风琴扩展/解决所有风格的问题

我正在尝试创建一个手风琴,只需单击一下即可展开/折叠所有部分.我还需要用户能够打开和关闭一次打开0-n部分的部分.使用stackoverflow和jquery论坛上的几个讨论,这里是我提出的解决方案:我已经实现了每个部分,因为它是自己的手风琴,其中每个都设置为collapsible = true.

<html>
    <head>
        <title>Accordion Test</title>

        <script type="text/javascript" src="../scripts/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" src="../scripts/jquery-ui-1.8.4.custom.min.js"></script>

        <link rel="stylesheet" href="../_templates/css/jquery-ui-1.8.6.custom.css"  type="text/css" />
        <link rel="stylesheet" href="../_templates/css/jquery.ui.accordion.css" type="text/css" />
    </head>

<body>
        <a onClick="expandAll()">Expand All</a>
        <br>
        <a onClick="collapseAll()">Collapse All</a>
            <div id="accordion1" class="accord">
            <h5><a href="#">section 1</a></h5>
            <div>
                    section 1 text  
            </div>
            </div>

            <!-- orders section -->
            <div id="accordion2" class="accord">
            <h5><a href="#">section 2</a></h5>
            <div>
                    section 2 text  
            </div>
            </div>

            <!--  section 3 -->
            <div id="accordion3" class="accord">
            <h5><a href="#">section 3</a></h5>
            <div>
                    section 3 text  
            </div>
            </div>

            <!-- section 4 --> …
Run Code Online (Sandbox Code Playgroud)

jquery-ui jquery-ui-accordion

11
推荐指数
1
解决办法
4万
查看次数

网络刮板可以绕过良好的油门保护吗?

假设数据源设置了严格的基于IP的节流.如果节流开始在下载1%的数据时拒绝其请求,那么网络抓取器是否有任何方式可以下载数据?

我能想到的黑客使用的唯一技术是某种代理系统.但是,似乎代理(即使速度快)最终都会达到节流.

更新:下面的一些人提到了像Yahoo Pipes和Tor这样的大型代理网络,但这些IP范围或已知的退出节点是否也不会被列入黑名单?

security http web-scraping

8
推荐指数
1
解决办法
2453
查看次数

有没有类似 Lisp 的用于 Python/Django 的 SLIME 的东西?

我知道 Django 控制台,它在某种程度上很有用,但是能够在控制台打开的情况下编辑代码真的很棒,Emacs 中的石灰 SLIME。有没有什么可以为 Django 或至少 Python 提供便利?

lisp python django slime

5
推荐指数
1
解决办法
384
查看次数

由于System.Web冲突,C#.NET DLL无法构建

我在Visual Studio C#Express 2010中遇到了类库的问题.该项目配置了.NET 4.0的目标框架(不是客户端配置文件).

在我的类库中,我添加了对System.Web的引用,以使URL编码适用于我的oAuth库.

在构建DLL和相关的测试应用程序时,我收到以下错误:

Error   1   The type or namespace name 'TwitterAPI' could not be found (are you missing a using directive or an assembly reference?)    C:\Users\sammarks\Documents\Programming\Twitter.NET\Tester\Program.cs   5   7   Tester
Run Code Online (Sandbox Code Playgroud)

并且,我收到以下警告消息:

Warning 2   The referenced assembly "C:\Users\sammarks\Documents\Programming\Twitter.NET\TwitterAPI\bin\Release\TwitterAPI.dll" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.   Tester
Run Code Online (Sandbox Code Playgroud)

我不知道为什么会这样,但这就是我来到这里的原因.我已经尝试将类库重新定位到3.5,但这并没有做什么,只是把它搞得更糟. …

.net c# visual-studio-2010

7
推荐指数
1
解决办法
1964
查看次数

如何在C#窗体窗体对话框中显示标准错误图标?

我想在Windows窗体对话框中使用标准错误图标(标准图标).如何将错误图标加载到图像中进行显示?

c# winforms

10
推荐指数
2
解决办法
7461
查看次数

在定义中将#a字符串化,为什么不好

#include <stdio.h>
#define print_int(a) printf("%s : %d\n",#a,(a))
int main(void) {
    int y = 10;
    print_int(y);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我正在上课,并被要求解释为什么这很糟糕。所以我想字符串化#a是问题。它确实有效,那么为什么会有危险呢?

c printf c-preprocessor

5
推荐指数
1
解决办法
974
查看次数

C++:为什么我对"std :: uninitialized_copy"的调用不起作用?

我构建了一个简单的类,它应该模仿std :: string类的功能(作为练习!):

#ifndef _STR12_1_H
#define _STR12_1_H

#include <string>
#include <iostream>

class Str12_1
{
public:

    typedef char* iterator;
    typedef const char* const_iterator;
    typedef long size_type;


    Str12_1();
    Str12_1(const Str12_1& str);
    Str12_1(const char *p);
    Str12_1(const std::string& s);

    size_type size() const;

    //Other member functions


private:
    iterator first;
    iterator onePastLast;
    iterator onePastAllocated;
};
Run Code Online (Sandbox Code Playgroud)

为了避免与"new"相关的开销(并增加我对<memory>标题的熟悉程度),我选择使用库的allocator模板类为我的字符串分配内存.以下是我在复制构造函数中使用它的示例:

#include <memory>
#include <algorithm>

using std::allocator;
using std::raw_storage_iterator;
using std::uninitialized_copy;


Str12_1::Str12_1(const Str12_1& str)
{
    allocator<char> charAlloc;
    first = charAlloc.allocate(str.size());
    onePastLast = onePastAllocated = first + str.size();
    *onePastLast = …
Run Code Online (Sandbox Code Playgroud)

c++ initialization allocator

2
推荐指数
1
解决办法
1105
查看次数

SWT表的"快速查找"

我有一个显示数据库输出的表,通常可以达到或超过10,000行.我正在寻求实现一个"快速查找"功能,允许用户轻松滚动到他们搜索的值的行.

这个想法与Chrome或Firefox的快速查找非常相似.所以:

  1. 用户点击"CTRL + F"
  2. 弹出一个框:
  3. 快速查找示例
  4. 然后,用户可以快速浏览表格,推送/或/ \到每个匹配的值

我的问题是,这样的表格是否已经存在?我看过NatTableXViewer,但它们看起来都是相当小的变化.

另一个我已经看过的图书馆就是这个非常贴近的版本是Lucene TableSearcher,不幸的是,它是专为过滤而不是突出显示而设计的.然而,这可能是一个值得研究的途径.

java eclipse swt jface

5
推荐指数
1
解决办法
1968
查看次数

用于测试API的Groovy

我正在编写一系列自动化的端到端测试用例,它们运行RestFUL API.

我有几个很好的测试脚本,用Groovy编写,提供了一些测试并建立了我们需要的信心,我们正在考虑将它们集成到夜间构建中,并允许QA团队运行它们.这是单元测试的一个步骤,因为我们正在研究完整的端到端工作流程,而不是原子步骤.

输出当前是人类可读的,每个测试条件打印出一行定义测试,读取的值和真/假以显示测试条件是否通过.

我想把它包装成一个更高级别的脚本,单独调用每个脚本,然后分析输出.我自己可以很容易地做到这一点,但是想知道是否已经有一个Groovy测试框架,所以我不再重新发明轮子.

testing groovy qa

5
推荐指数
0
解决办法
4111
查看次数