다음 SQL이 있습니다. LINQ로 변환해야합니다.SQL을 LINQ로 변환
ALTER VIEW [dbo].[vwRptBorrowerAccount]
AS
SELECT dbo.tblAccount.[Creditor Registry ID], dbo.tblAccount.[Account No], dbo.tblAccount.[Date Opened], dbo.tblAccount.[Account Status ID],
dbo.tblAccount.[Date First Reported], dbo.tblAccount.[Credit Limit], dbo.tblAccount.Balance, dbo.tblAccount.[Minimum Installment], dbo.tblAccount.[Account Type],
dbo.tblAccount.Term, dbo.tblAccount.Purpose, dbo.tblAccount.[Account Owner Notes], dbo.tblAccount.[Creditor Notes], dbo.tblAccount.Collateral,
dbo.tblAccount.[Collateral Value], dbo.tblAccount.[Legal Status ID], dbo.tblAccount.[Legal Status Date], dbo.tblAccount.LastUpdatedBy,
dbo.tblAccount.LastUpdated, dbo.tblAccount.[Unique ID], dbo.tblAccount.[Account Status Date], dbo.tblAccount.Payment, dbo.tblAccount.[Payment Date],
dbo.tblAccount.[Balance Date], dbo.tblAccount.[Term Frequency], dbo.tblAccount.[State Change Date],
dbo.fn_GetAccountTypeDescription(dbo.tblAccount.[Account Type]) AS [Account Type Description], dbo.tblBusiness.[Business Name] AS CreditorName,
dbo.tblBusiness.Address AS CreditorAddress, dbo.tblBusiness.City AS CreditorCity, dbo.tblBusiness.State AS CreditorState,
dbo.tblLegalStatus.[Legal Status Description] AS [Legal Status], dbo.tblAccountStatus.[Account Status Description] AS [Account Status],
dbo.tblAccountOwner.[Account Owner Registry ID]
FROM dbo.tblAccount INNER JOIN
dbo.tblAccountOwner ON dbo.tblAccount.[Creditor Registry ID] = dbo.tblAccountOwner.[Creditor Registry ID] AND
dbo.tblAccount.[Account No] = dbo.tblAccountOwner.[Account No] INNER JOIN
dbo.tblBusiness ON dbo.tblAccount.[Creditor Registry ID] = dbo.tblBusiness.[Registry ID] INNER JOIN
dbo.tblAccountStatus ON dbo.tblAccount.[Account Status ID] = dbo.tblAccountStatus.[Account Status ID] INNER JOIN
dbo.tblLegalStatus ON dbo.tblAccount.[Legal Status ID] = dbo.tblLegalStatus.[Legal Status ID]
WHERE (dbo.tblAccount.[Account Type] NOT IN ('CA00', 'CA01', 'CA03', 'CA04', 'CA02', 'PA00', 'PA01', 'PA02', 'PA03', 'PA04'))
[EDITED] 과 기능의 세부 사항은 다음과 같습니다
CREATE FUNCTION [fn_GetAccountTypeDescription]
(
-- Add the parameters for the function here
@accountType varchar(max)
)
RETURNS varchar(max)
with schemabinding
AS
BEGIN
-- Declare the return variable here
DECLARE @Result varchar(max)
-- Add the T-SQL statements to compute the return value here
IF EXISTS(SELECT Abbreviation FROM dbo.tblAccountType WHERE [Account Type Code] = @accountType)
BEGIN
SELECT @Result = Abbreviation FROM dbo.tblAccountType WHERE [Account Type Code] = @accountType
END
ELSE
BEGIN
SELECT @Result = @accountType
END
-- Return the result of the function
RETURN @Result
END
당신이 LINQ로 변환하는 방법을 제안시겠습니까? 조인을 사용하고 싶지 않습니다.
연관을 사용하고 싶습니다. 엔티티는 관련 속성을 통해 연결됩니다. – DotnetSparrow
어색한 비트는'fn_GetAccountTypeDescription' – Jodrell
@Jodrell 될 것입니다 : 난 당신이 얻을 이런 종류의 작업을 수행하도록 설계 응용 프로그램을 사용할 수 – DotnetSparrow