프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / FinalService / FinalServiceBase / KCOMDataModel / Common / SelectMembersQuery.cs @ 42d49521

이력 | 보기 | 이력해설 | 다운로드 (1.73 KB)

1
using KCOMDataModel.DataModel;
2
using System;
3
using System.Collections.Generic;
4
using System.Linq;
5
using System.Text;
6
using System.Threading.Tasks;
7

    
8
namespace KCOMDataModel.Common
9
{
10
    public static class ObjectQuery
11
    {
12
        public static List<MEMBER> GetMemberQuery(System.Data.Objects.ObjectContext context, string UserID)
13
        {
14
            List<MEMBER> result = new List<MEMBER>();
15

    
16
            try
17
            {
18
                string query = "SELECT members.ID,members.NAME,members.DEPARTMENT FROM CIEntities.MEMBER as members where members.ID = @userId";
19

    
20
                var param = new[] { new System.Data.Objects.ObjectParameter("userId", UserID) };
21

    
22
                System.Data.Objects.ObjectQuery<System.Data.Common.DbDataRecord> memberQuery
23
                              = context.CreateQuery<System.Data.Common.DbDataRecord>(query, param);
24

    
25
                if (memberQuery.Count() > 0)
26
                {
27
                    foreach (var dataRecord in memberQuery)
28
                    {
29
                        MEMBER member = new MEMBER();
30

    
31
                        string userName = dataRecord["NAME"]?.ToString().Trim();
32
                        string ID = dataRecord["ID"]?.ToString().Trim();
33
                        string depatment = dataRecord["DEPARTMENT"]?.ToString().Trim();
34

    
35
                        member.NAME = userName;
36
                        member.ID = ID;
37
                        member.DEPARTMENT = depatment;
38

    
39
                        result.Add(member);
40
                    }
41
                }
42
            }
43
            catch (Exception ex)
44
            {
45
                throw new Exception("GetMember(System.Data.Objects.ObjectContext context, string UserID) ", ex);
46
            }
47

    
48
            return result;
49
        }
50
    }
51
}
클립보드 이미지 추가 (최대 크기: 500 MB)