EF中使用SqlQuery執行語句


            string sql = @"
                        SELECT     B.[FId], 
                                A.[FileTypeNo], 
                                A.[FtypeName], 
                                A.[FtypeId], 
                                A.[ProcessName],
                                A.[ProcessId],
                                B.[InstanceId],
                                B.[Status]
                        FROM    [Process] AS A
                        INNER   JOIN [ProcessInstance] AS B ON A.[ProcessId]=B.[ProcessId]
                        WHERE   B.[UserId]=@userId AND A.[FileTypeNo]=@FileTypeNo";
            using(DbHelper<Process> pDb = new DbHelper<Process>())
            {
                var userNameParam = new System.Data.SqlClient.SqlParameter
                {
                    ParameterName = "@userId",
                    Value = userId
                };
                var fileTypeNoParam = new System.Data.SqlClient.SqlParameter
                {
                    ParameterName = "@fileTypeNo",
                    Value = fileTypeNo
                };
                var info = pDb.Database.SqlQuery<ProcessAllInfoDto>(sql, userNameParam, fileTypeNoParam).FirstOrDefault();
                return info;
            }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM