0
我正在轉換遺留系統的數據層使用NHibernate。舊的數據庫加載了我想要映射的存儲過程。我被事物的命名所撕毀。這些特效不返回簡單的實體,它們返回一團糟。一個例子是這樣的:NHibernate存儲過程命名
USE [MYDB]
GO
/****** Object: StoredProcedure [dbo].[GetInvoiceRenewals] Script Date: 06/21/2012 10:24:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[GetInvoiceRenewals]
@ClientId int,
@UserId int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
IF (@ClientId IN (SELECT ClientId FROM dbo.UserClientIds(@UserId)))
BEGIN
SELECT I.InvoiceId, I.ClientId, I.InvoiceTypeId, I.InvoiceNumber, I.QuoteNumber, I.PONumber,
I.TotalListPrice, I.EstimatedFee, I.ActualFee, I.DateCreated, u.firstname + ' ' + u.lastname as 'UserCreated',i.billingAddressID,i.shippingAddressID,
I.ActualClientPrice,
(select InvoiceStatus from InvoiceStatus where invoiceStatusID = (Select Case When Not Exists (Select * from InvoiceStatusHistory where InvoiceId=I.InvoiceID) Then 1
Else (Select top 1 InvoiceStatusID from InvoiceStatusHistory where InvoiceId=I.InvoiceID Order By ActionDate Desc) End)) as Status
FROM Invoice I, [user] u
WHERE I.ClientId = @ClientId AND I.IsActive = 1 AND I.InvoiceTypeId = 3 and u.userID = i.userCreated
END
END
--Select Case When Not Exists (Select * from InvoiceStatusHistory where InvoiceId=I.InvoiceID) Then 1
-- Else (Select InvoiceStatusID from InvoiceStatusHistory where InvoiceId=I.InvoiceID) End
--
--InvoiceStatusID is NULL then 1 else InvoiceStatusID END from InvoiceStatusHistory
-- where InvoiceId=1860 Order By ActionDate Desc
現在的圖片數以百計。我顯然會編寫一個腳本來將所有這些生成到HBM文件中,並創建實體。我在尋找的是這些proc實體的良好命名結構?有什麼想法嗎?
我想要取消所有的存儲過程。我的方法是慢遷移,使用NHibernates CreateSQLQuery將整個數據層轉換爲NHibernate,包括舊的特效。一旦我將所有東西都運行起來,我就可以慢慢地開始在linq中獲取所有東西,並從存儲的特效庫中剔除業務邏輯。再次,我只是想要命名我將映射存儲過程的實體。 –