小编fjl*_*eon的帖子

在 .NET 中连接到 SQL Server 时,指定的网络名称不再可用

我重新安装了我的主要工作电脑,但在 5 个月后没有重新安装 Visual Studio。现在我做了并开始了我的旧项目,现在它没有运行。

连接到 SQL Server 时出现超时错误,因此我增加了连接字符串中的超时,现在出现错误:

[Win32Exception (0x80004005): The specified network name is no longer available]

[SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)]
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) +1004
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey …
Run Code Online (Sandbox Code Playgroud)

c# sql-server visual-studio-2015

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

如何将 LINQ 结果传递给方法?

高效的数据结构来保存员工的活动?,我有一个 ActividadEmpleado 类型的列表,声明为:

public string Empleado { get; set; }
public DateTime Fecha { get; set; }
public string Actividad { get; set; }
Run Code Online (Sandbox Code Playgroud)

LINQ 查询变量以我需要的方式对结果重新排序,即按日期存储,然后按 ActividadEmpleado 和字符串存储。但是,var 类型不能传递给方法,所以搜索这个网站我发现我要么需要创建一个类来存储结果或修改 LINQ 变量以返回一个列表,但我在正确声明方面遇到了问题.

LINQ 变量是:

var queryActividades = listaActividad
                .GroupBy(a => a.Fecha, (fecha, fechaActividades) => new
                {
                    Fecha = fecha,
                    FechaActividades = fechaActividades
                        .GroupBy(a => a.Empleado, (nombreEmpleado, actividadesEmpleado) => new
                        {
                            Actividades = actividadesEmpleado,
                            NombreEmpleado = nombreEmpleado
                        })
                        .OrderBy(a => a.NombreEmpleado)
                })
                .OrderBy(a => a.Fecha);
Run Code Online (Sandbox Code Playgroud)

Visual Studio 说 queryActividades 是: …

c# linq anonymous-types data-structures

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