첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ 예제 모델

public class MenuModel
{
    public string ID { get; set; }

    ...
}

public class MenuStructureModel
{
    public string MENU_TEMPLATE_ID { get; set; }

    public string TARGET { get; set; }

    public string ID { get; set; }

    ...

    public string MENU_ID { get; set; }

    ...

    public MenuModel Menu { get; set; }

    ...
}

 

728x90

 

▶ 예제 코드

using System.Collections.Generic;
using System.Data;

...

private IDbConnection connetcion;

...

string sql = @"
SELECT
    PARENT.*
   ,CHILD.*
FROM      COM_MENU_STRUCTURE CHILD
LEFT JOIN COM_MENU           PARENT ON PARENT.ID = CHILD.MENU_ID
WHERE CHILD.MENU_TEMPLATE_ID = @MENU_TEMPLATE_ID
AND   CHILD.TARGET           = @TARGET
ORDER BY CHILD.ROWID ASC;
";

var result = this.connection.QueryIncludingParent<MenuModel, string, MenuStructureModel>
(
    sql,
    parent => parent.ID,
    (child, parent) => { child.Menu = parent; },
    parameter : new { MENU_TEMPLATE_ID = menuTemplateID, TARGET = target },
    splitOn : "MENU_TEMPLATE_ID"
);

 

728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요