39. C# LYNQ(링크),여러 데이터소스원본 질의,Lowest,select new
여러 데이터 원본에 질의하려면 from문을 중첩해서 사용해야 한다.
예제를 보면서 이해하자.
using System;
using System.Linq;
using System.Collections.Generic;
namespace from
{
class OnjProfile
{
public string Name { get; set; }
public string Url { get; set; }
public int[] Num { get; set; }
}
class Onj
{
static void Main(string[] args)
{
OnjProfile[] onjProfile = {
new OnjProfile() {Name="ONJSYSTEM", Url="onjsystems.co.kr", Num=new int[] {5919, 4790}},
new OnjProfile() {Name="오라클자바커뮤니티프로그래밍실무학원", Url="oraclejavacommunity.com", Num=new int[] {8888, 9999}},
new OnjProfile() {Name="오라클자바커뮤니티", Url="oraclejavanew.kr", Num=new int[] {1111, 2222}}
};
var onjs = from onj in onjProfile
from num in onj.Num
where num > 1111
orderby num
select new
{
onj.Name,
Lowest = num
};
foreach (var o in onjs)
Console.WriteLine("{0}, {1}", o.Name, o.Lowest);
}
}
}
[결과]
오라클자바커뮤니티, 2222
ONJSYSTEM, 4790
ONJSYSTEM, 5919
오라클자바커뮤니티프로그래밍실무학원, 8888
오라클자바커뮤니티프로그래밍실무학원, 9999
![]() | ![]() ![]() | 12-27 | 2708 | |
![]() | ![]() ![]() | 12-11 | 1956 | |
53 | ![]() ![]() | 03-15 | 1781 | |
52 | ![]() ![]() | 01-31 | 1936 | |
51 | ![]() ![]() | 01-31 | 2831 | |
50 | ![]() ![]() | 01-31 | 1487 | |
49 | ![]() ![]() | 01-19 | 1819 | |
48 | ![]() ![]() | 01-11 | 1694 | |
47 | ![]() ![]() | 01-03 | 2237 | |
46 | ![]() ![]() | 12-27 | 2708 | |
45 | ![]() ![]() | 12-19 | 1916 | |
44 | ![]() ![]() | 12-14 | 1894 | |
43 | ![]() ![]() | 12-11 | 1956 | |
42 | ![]() ![]() | 12-09 | 1541 | |
41 | ![]() ![]() | 12-01 | 1767 | |
40 | ![]() ![]() | 12-01 | 1973 | |
39 | ![]() ![]() | 12-01 | 1410 |
댓글 없음:
댓글 쓰기