private sys_User GetUserInfo() { sys_User model = null; var userId = Convert.ToInt32(AccountHelper.GetAccountUserId()); var list = BLLSingleton.Instance.IUserService.GetListBy(c => c.UserId == userId); if (list != null) model = list.FirstOrDefault();…
最近在开发mvc3的时候发现了一个问题,就是如何在view页面显示多表查询的数据,最简单的办法就是使用viewmodel了,以下本人使用viewmodel来实现多表查询的3中方法, 先贴代码再说: 1 第一种是将页面显示多表的数据(也就是汇总各个model表的字段),然后再viewmodel中显示 public class ResultAdList { public int A_Id; public string A_userid; public int B_Id; public string…
mvc linq to sql,linq to entity,sum,null 昨天写了段sum的统计语句, decimal sums sums = ( from fac in db.Apply where fa.state == 1 select fac.num ).Sum(), 然后一运行,报错 Message=The cast to value type 'System.Decimal' failed because the materialized value is null. Eit…
关于linq的多表联查效果的实现: 后台多表查询 内连接: SELECT [Extent2].[partID] AS [partID], [Extent1].[userName] AS [userName], [Extent3].[partName] AS [partName]FROM [dbo].[User] AS [Extent1]INNER JOIN [dbo].[User_partB] AS [Extent2] ON [Extent1].[userGUID] = [Extent2].[…