如何在c#中选择两列合并lambda表达式?
我想连接到数据库并选择数据库表合并这两列。此列返回此查询应返回我选择的记录。 比如, 连接信息 列为: 地址城市 表名:地址 地址:2 城市:B 我想得出以下结论: 地址+城市:2B 连接信息2 列为: 地址城市 表名:地址 地址:3 城市:C 我想得出以下结论: 地址+城市:3C 如果输入3c,则值为3c,如果它在第二个数据库中,我想添加它 我正在连接两个数据库。我将添加它存在于哪个数据库中的地址城市。那么,我如何使用select来实现这一点呢如何在c#中选择两列合并lambda表达式?,c#,entity-framework,C#,Entity Framework,我想连接到数据库并选择数据库表合并这两列。此列返回此查询应返回我选择的记录。 比如, 连接信息 列为: 地址城市 表名:地址 地址:2 城市:B 我想得出以下结论: 地址+城市:2B 连接信息2 列为: 地址城市 表名:地址 地址:3 城市:C 我想得出以下结论: 地址+城市:3C 如果输入3c,则值为3c,如果它在第二个数据库中,我想添加它 我正在连接两个数据库。我将添加它存在于哪个数据库中的地址城市。那么,我如何使用select来实现这一点呢 SqlConnection conn =
SqlConnection conn = new SqlConnection(myconnectınformation);
GetTables().Address.Select(o => new Model { Address = o.Address, City = o.City });
SqlConnection conn = new SqlConnection(myconnectınformation2);
GetTables().Address.Select(t => new Model { Address = t.Address, City = t.City });
SqlConnection conn = new SqlConnection(myconnectınformation);
GetTables().Address.Select(o => new Model { Address = o.Address, City = o.City });
SqlConnection conn = new SqlConnection(myconnectınformation2);
GetTables().Address.Select(t => new Model { Address = t.Address, City = t.City });
不出错,但不合并select数据库表。GetTables().Address.select(t=>new Model{Address=t.Address+t.City});请说明“如果它在第二个数据库中,我想添加它”。@MoinulIslam我只想选择输入值的组合值。如果在插入连接数据库后选择。然后尝试第一条注释的代码。您可以使用GetTables().Address.Select(t=>new{Address=t.Address+t.City});