问题列表 - 第7403页

实体框架 - Linq To Entities - 多对多查询问题

我在查询Linq To Entities中的多对多关系时遇到问题.我基本上尝试使用Linq复制此查询:

Select * 
FROM Customer 
LEFT JOIN CustomerInterest ON Customer.CustomerID = CustomerInterest.CustomerID
LEFT JOIN Interest ON CustomerInterest.InterestID = Interest.InterestID
WHERE Interest.InterestName = 'Football'
Run Code Online (Sandbox Code Playgroud)

我环顾网络并没有找到任何合适的例子来说明这一点.我最接近的是:

List<Customer> _Customers = (from _LCustomers in _CRM.Customer.Include("CustomerInterest.Interest")
                                  where _LCustomers.CustomerInterest.Any(x => x.Interest.InterestName == "Football")
                                  select _LCustomers).ToList();
Run Code Online (Sandbox Code Playgroud)

这样做的问题是,如果客户有多个兴趣而其中一个是"足球",则返回所有这些兴趣.我也看过All()有逆问题,即只有他们有一个兴趣才会返回,而且只有足球,如果他们有两个,而其中一个不是足球,则不返回任何东西.

有人有任何想法吗?

linq-to-entities many-to-many entity-framework left-join

6
推荐指数
2
解决办法
2万
查看次数

Python中epoll如何检测客户端关闭?

这是我的服务器

"""Server using epoll method"""

import os
import select
import socket
import time

from oodict import OODict

addr = ('localhost', 8989)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(addr)
s.listen(8)
s.setblocking(0) # Non blocking socket server
epoll = select.epoll()
epoll.register(s.fileno(), select.EPOLLIN) # Level triggerred

cs = {}
data = ''
while True:
    time.sleep(1)
    events = epoll.poll(1) # Timeout 1 second
    print 'Polling %d events' % len(events)
    for fileno, event in events:
        if fileno == s.fileno():
            sk, addr = s.accept()
            sk.setblocking(0) …
Run Code Online (Sandbox Code Playgroud)

python epoll

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

是否有太多左手加入代码味道?

例如,如果您在查询中有> 5个左连接是代码味道有...

  • 你的设计出了什么问题?
  • 你在一个查询中做得太多了吗?
  • 你的数据库太规范化了吗?

sql sql-server-2005 left-join

33
推荐指数
4
解决办法
8461
查看次数

如何查找活动的app.config文件的路径?

我正在尝试完成此异常处理程序:

if (ConfigurationManager.ConnectionStrings["ConnectionString"]==null)
{
    string pathOfActiveConfigFile = ...?
    throw new ConfigurationErrorsException(
       "You either forgot to set the connection string, or " +
       "you're using a unit test framework that looks for  "+
       "the config file in strange places, update this file : " 
       + pathOfActiveConfigFile);
}
Run Code Online (Sandbox Code Playgroud)

当我使用nUnit时,这个问题似乎只发生在我身上.

.net c# nunit configurationmanager app-config

163
推荐指数
6
解决办法
14万
查看次数

在Hibernate Envers中获取以前版本的实体

我有一个由Hibernate(via EntityManager)加载的实体:

User u = em.load(User.class, id)
Run Code Online (Sandbox Code Playgroud)

该课程由Hibernate Envers审核.如何加载以前版本的用户实体?

java jboss hibernate hibernate-envers

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

我们不应该在WinForms应用程序中使用System.Web.Caching.Cache类吗?

我看过几篇文章/博客文章,主张在不适用于Web的应用程序中使用System.Web.Caching.Cache,但是,MSDN文档非常明确地指出

Cache类不适用于ASP.NET应用程序之外.它的设计和测试用于ASP.NET,以便为Web应用程序提供缓存.在其他类型的应用程序中,例如控制台应用程序或Windows窗体应用程序,ASP.NET缓存可能无法正常工作.

文档是错误的,还是我们真的不应该使用这个类?如果是后者,会出现什么问题?我们的平台是Winforms/.NET 3.5.

.net caching winforms

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

无法在Bash 4中使用Checkjobs和Autocd

Bash 4中有新选项:checkjobs和autocd.但是,我没有找到他们的文档

man bash
Run Code Online (Sandbox Code Playgroud)

我跑得不成功

{checkjobs,autocd}
Run Code Online (Sandbox Code Playgroud)

我在发行说明中找到了以下内容

 There is a new `checkjobs` option that causes the shell to check for and
 report any running or stopped jobs at exit
Run Code Online (Sandbox Code Playgroud)

There is a new `autocd` option that, when enabled, causes bash to attempt
to `cd` to a directory name that is supplied as the first word of a
simple command.
Run Code Online (Sandbox Code Playgroud)

你怎么能使用autocd和checkjobs?

bash bash4

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

psycopg2"TypeError:在字符串格式化期间不是所有参数都被转换"

我正在尝试将二进制数据(漩涡哈希)插入到PG表中并收到错误:

TypeError: not all arguments converted during string formatting 
Run Code Online (Sandbox Code Playgroud)

码:

cur.execute("""
    INSERT INTO
        sessions
        (identity_hash, posted_on)
    VALUES
        (%s, NOW())
""", identity_hash) 
Run Code Online (Sandbox Code Playgroud)

我尝试在插入之前将conn.Binary("identity_hash")添加到变量,但得到相同的错误.

identity_hash列是bytea.

有任何想法吗?

python postgresql psycopg2

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

.NET准则:为什么两个字母的首字母缩写词例外?

微软框架设计指南定义了以下内容:

"将两个字符缩写词的两个字符大写,除了驼峰标识符的第一个单词"

因此,对于首字母缩略词定义的例外仅包含两个字母,因为具有三个或更多字母的首字母缩略词是"正确"的骆驼套装或pascal套装.

问题是:为什么会有例外,即背后的理由是什么?我无法从FDG书或Abrams和Cwalina的博客中得到解释.

.net naming-conventions

6
推荐指数
1
解决办法
1342
查看次数

C#调用图生成工具

我刚收到一大堆(大多数是未记录的)C#代码,我想在潜入并开始重构之前想象它的结构.我在过去(使用其他语言)使用生成调用图的工具完成了这项工作.

你能推荐一个好的工具来促进C#中的结构发现吗?

UPDATE

除了这里提到的工具,我已经看到(通过电子管)人们说.NET ReflectorCLR Profiler具有此功能.有这些经验吗?

.net c# code-analysis call-graph

30
推荐指数
6
解决办法
2万
查看次数