求转换SQL++++++++++++++++++++++++++在线等!!!!!!!!!!!!!!!!!!!!!!!
- SQL code
SELECT TOP 1000 [ID] ,[AssetID] ,[DistributeTo] ,[DistributeTime] ,[DistributeUse] ,[Remark] ,[OperUser] ,[DistributeToDepart] FROM [Asset].[dbo].[AM_AssetDistributionInfo] where AssetID not in (select AssetID from AM_AssetWasteInfo) and AssetID='2011205070013'
Expression<Func<v_AssetYes, bool>> express = PredicateExtensions.True<v_AssetYes>();
if (!string.IsNullOrEmpty(Request["AssetCode"]))
{
express = express.And(t => t.AssetCode.StartsWith(Request["AssetCode"].Trim()));
}
not in条件 跟这里的and是一起的;怎么加上来?
PagedList<v_AssetYes> model = db.v_AssetYes.Where<v_AssetYes>(expr).OrderBy(p => p.cdepname).OrderBy(p => p.cpsn_name).ToPagedList(id ?? 1, 12);
[解决办法]
试试这样
- C# code
var query= (from t1 in AM_AssetDistributionInfo where !(from t2 in AM_AssetWasteInfo select AssetID).Contains(AssetID) && AssetID=='2011205070013' select new{t1.AssetID,t1.DistributeTo,t1.DistributeUse}).Take(1000); query.ToList();
[解决办法]
var query= db.v_AssetYes.Where<v_AssetYes>(expr).OrderBy(p => p.cdepname).ThenBy(p => p.cpsn_name);
PagedList<v_AssetYes> model=query.Where(p=>!(db.AM_AssetWasteInfo.Select(q=>q.AssetID)).Contains(p.AssetID )).ToPagedList(id ?? 1, 12);
var sss = model.ToList();