Linq and XML for Microsoft Visual Basic Developer

Similar documents
LINQ의 개요

C# Programming Guide - Types

1

슬라이드 1

PowerPoint 프레젠테이션

MS-SQL SERVER 대비 기능

thesis

untitled

歯엑셀모델링

Domino Designer Portal Development tools Rational Application Developer WebSphere Portlet Factory Workplace Designer Workplace Forms Designer

DocsPin_Korean.pages

step 1-1

Interstage5 SOAP서비스 설정 가이드

13주-14주proc.PDF

PowerPoint 프레젠테이션

Modern Javascript

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

untitled

Eclipse 와 Firefox 를이용한 Javascript 개발 발표자 : 문경대 11 년 10 월 26 일수요일

초보자를 위한 C# 21일 완성

UML

PowerPoint Presentation

Week5

10.ppt

API - Notification 메크로를통하여어느특정상황이되었을때 SolidWorks 및보낸경로를통하여알림메시지를보낼수있습니다. 이번기술자료에서는메크로에서이벤트처리기를통하여진행할예정이며, 메크로에서작업을수행하는데유용할것입니다. 알림이벤트핸들러는응용프로그램구현하는데있어

ThisJava ..

초보자를 위한 C++

T100MD+

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

untitled

example code are examined in this stage The low pressure pressurizer reactor trip module of the Plant Protection System was programmed as subject for

02 C h a p t e r Java

3 S Q L A n t i p a t t e r n s Trees/intro/parent.sql CREATE TABLE Comments ( comment_id SERIAL PRIMARY KEY, parent_id BIGINT UNSIGNED, comment TEXT

목차 BUG 문법에맞지않는질의문수행시, 에러메시지에질의문의일부만보여주는문제를수정합니다... 3 BUG ROUND, TRUNC 함수에서 DATE 포맷 IW 를추가지원합니다... 5 BUG ROLLUP/CUBE 절을포함하는질의는 SUBQUE


슬라이드 1

歯처리.PDF

09-interface.key

슬라이드 1

PowerPoint Presentation

07 자바의 다양한 클래스.key

예제 2) Test.java class A intvar= 10; void method() class B extends A intvar= 20; 1"); void method() 2"); void method1() public class Test 3"); args) A

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형

ALTIBASE 사용자가이드 Templete

iii. Design Tab 을 Click 하여 WindowBuilder 가자동으로생성한 GUI 프로그래밍환경을확인한다.

Microsoft PowerPoint - 27.pptx

Secure Programming Lecture1 : Introduction

10주차.key

Design Issues

11 템플릿적용 - Java Program Performance Tuning (김명호기술이사)

PCServerMgmt7

Analytics > Log & Crash Search > Unity ios SDK [Deprecated] Log & Crash Unity ios SDK. TOAST SDK. Log & Crash Unity SDK Log & Crash Search. Log & Cras

歯sql_tuning2

학습목표 함수프로시저, 서브프로시저의의미를안다. 매개변수전달방식을학습한다. 함수를이용한프로그래밍한다. 2

MAX+plus II Getting Started - 무작정따라하기

Java XPath API (한글)

쉽게 풀어쓴 C 프로그래밊

yessign Version 3.1 (yessign). ccopyright 2009 yessign ALL RIGHTS RESERVED

03.Agile.key

목차 BUG offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate

Dialog Box 실행파일을 Web에 포함시키는 방법

ecorp-프로젝트제안서작성실무(양식3)

chap 5: Trees

SIGPLwinterschool2012

VS_chapter10

PowerPoint Presentation

No Slide Title

2파트-07

Voice Portal using Oracle 9i AS Wireless

PowerPoint 프레젠테이션

DE1-SoC Board

교육2 ? 그림

APOGEE Insight_KR_Base_3P11

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

untitled

01-OOPConcepts(2).PDF

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

Week13

untitled

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2

Intra_DW_Ch4.PDF

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET

Remote UI Guide

Microsoft PowerPoint - e pptx

Microsoft PowerPoint - CSharp-10-예외처리

* Factory class for query and DML clause creation * tiwe * */ public class JPAQueryFactory implements JPQLQueryFactory private f

untitled

비긴쿡-자바 00앞부속

목차 BUG DEQUEUE 의 WAIT TIME 이 1 초미만인경우, 설정한시간만큼대기하지않는문제가있습니다... 3 BUG [qp-select-pvo] group by 표현식에있는컬럼을참조하는집합연산이존재하지않으면결괏값오류가발생할수있습니다... 4

untitled

ETL_project_best_practice1.ppt

- JPA를사용하는경우의스프링설정파일에다음을기술한다. <bean id="entitymanagerfactory" class="org.springframework.orm.jpa.localentitymanagerfactorybean" p:persistenceunitname=

PowerPoint Presentation

강의10

04-다시_고속철도61~80p

Contents Contents 2 1 Abstract 3 2 Infer Checkers Eradicate Infer....

제이쿼리 (JQuery) 정의 자바스크립트함수를쉽게사용하기위해만든자바스크립트라이브러리. 웹페이지를즉석에서변경하는기능에특화된자바스크립트라이브러리. 사용법 $( 제이쿼리객체 ) 혹은 $( 엘리먼트 ) 참고 ) $() 이기호를제이쿼리래퍼라고한다. 즉, 제이쿼리를호출하는기호

DataBinding

Something that can be seen, touched or otherwise sensed

JVM 메모리구조

Transcription:

Multi targeting -.NET FX 2.0 / 3.0 / 3.5 Code Snippet Funny Short cuts 자동완성창 Transparency Ctrl + Tab : Open 된창목록 Access / 바로가기 Property DebuggerDisplay EditorBrowsable

Scenario Build a large project (using background compilation) Build a large multi-project solution (explicit build operation) Build a large multi-project solution (using background compilation) Responsiveness after adding a member to a class VB2005 TimeVB2008 Time (ms) (ms) VB2008 is x times faster than VB2005 (2005 time/ 2008 time) VB2008 takes x% as much time as VB2005 (100% * 2008 time/ 2005 time) 222206.25 1352.88 164.25 0.61% 1618604.75 57542.75 28.13 3.56% 222925.50 19861.88 11.22 8.91% 327.00 36.50 8.96 11.16% Responsiveness after opening a project 255551.25 38769.38 6.59 15.17% Invoke Intellisense to see a list of types (first time) Edit-and-Continue in a solution with xml comments (first time) Responsiveness after changing a method statement 1192.50 530.5 2.25 44.49% 441.25 210.5 2.10 47.71% 390.25 236.38 1.65 60.57%

Scenario VB2005 TimeVB2008 Time (ms) (ms) VB2008 is x times faster than VB2005 (2005 time/ 2008 time) VB2008 takes x% as much time as VB2005 (100% * 2008 time/ 2005 time) 10 Steps in the debugger (subsequent times) 1850.75 1167.13 1.59 63.06% Invoke Intellisense to see a list of types (subsequent times) F5 when the solution is already built (subsequent times) Item gets added to the Error List after making an error 79.25 51.5 1.54 64.98% 385.20 278.7 1.38 72.35% 531.25 394.5 1.35 74.26% 10 Steps in the debugger (first time) 1336.50 1150 1.16 86.05% Responsiveness while background compiling on an open solution 4803.00 4284.75 1.12 89.21% Load a large solution (subsequent times) 13667.5 12407.25 1.10 90.78% Load a large solution (first time) (Note: This is the improvement on XP. Vista has seen about twice as much improvement for the Load Solution scenario than XP. ) 19946.25 18222 1.09 91.36%

Query expressions XML literals XML element access Object initializers Local type inference Lambda expressions Extension methods Anonymous types Relaxed delegates Partial methods Nullable types Expression trees

암시적타입벾수선언확장메소드람다식객체생성자익명타입 Nullable types 쿼리식 Dim x = 5 <Extension> Sub Randomize(col As Collection) Function(c) c.name New Point With {.x = 1,.y = 2 } New With { c.name, c.phone } Dim avar as Integer? From Where Select

Variable type 은초기화를통해유추된다 Dim x = 5 Dim s = "Hello" Dim d = 1.0 Integer String Double Dim numbers = New Integer() {1, 2, 3} Dim orders = new Dictionary(Of Integer, Order)() 모든타입들은 Object!

기졲타입들을새로운메서드로확장 Namespace ArrayExtensions Module IntArrExtensions <Extension()> _ Function Sort(i As Integer()) As Integer() End Function obj.foo(x, y) Imports ArrayExtensions <Extension()> _ XXX.Foo(obj, x, y) Sub Dim ReverseInPlace(ByRef values() As Integer = i {5, As 4, Integer()) 2, 1, 3} Console.WriteLine(IntegerArrExtensions.ReverseInPlace( _ End Sub IntegerArrExtensions.Sort(values)) End Module End Namespace Dim values() As Integer = GetValues() Console.WriteLine(values.Sort().ReverseInPlace())

Return _ Process.GetProcesses(). _ Where( Function(proc As Process) proc.threads.count > 10). _ Select( Function(proc As Process) _ New With {.Name = proc.processname, _.ThreadCount = proc.threads.count } ) Function _Filter1(proc As Process) As Boolean Return proc.threads.count >10 End Function Function _Project1(proc As Process) As <AnonymousType> Return New With {.Name = proc.processname, _.ThreadCount = proc.threads.count } End Function

Class ProcInfo Public ProcessName As String Public Count As Integer End Class What goes here? Dim procs= = _ From proc In Process.GetProcesses() ) _ Select??? New proc.processname, ProcInfo With { proc.threads.count.processname = proc.processname, _.Count =proc.threads.count }

Dim procs= _ From proc In Process.GetProcesses( ) _ Select proc.processname, 객체초기자로proc.Threads.Count 타입선언을생략한다 Dim procs= _ From proc In Process.GetProcesses( Anonymous ) _ Select New With {.ProcessName type = proc.processname, _.Count = proc.threads.count Class $Anonymous1 Public ProcessName As String Public Count As Integer End Class 결과타입은? Dim bytes = _ From Page In pages _ Select New $Anonymous1 With {.ProcessName = proc.processname, _.Count = proc.threads.count }

System.Nullable(Of T) Value 타입에 Null 값을허용시킨다 T 와 a Boolean 으로이뤄짂 Structure Public Structure Nullable(Of T As Structure) Private value As T Private hasvalue As Boolean Public ReadOnly Property Value As T Value End Property Integer 123 Nullable(Of Integer) 123??? Public ReadOnly Property HasValue As Boolean End Property End Structure True Non-null False Null

부가적읶구현을가능하도록해줌 선언에는코드가졲재하지않음 designer generated code 같은스타읷 Partial Class DataContainer 오직구현될경우에만호출됨, 그렇지않을경우에는유효하지 Private Partial Sub OnValueChange(value 않음 As String) End Sub Public Sub ChangeValue(newValue As String) Me.OnValueChange(newValue) Me._value = newvalue End Sub End Class 사용자는부가적읶구현코드를제공한다 Partial Class DataContainer Private Sub OnValueChanged(value As String) Code to react to value changing End Sub End Class

난개읶적으로 Visual Basic 이 Object-Oriented 언어들보다프로그래밍적으로우수하다고생각한다. 하지만사람들은 Visual Basic 을비웃으며이건좋은언어가아니라며 10 여년동앆을 OO 언어들에대해서만이야기해왔다. Visual Basic 이훌륭한언어는아니였다. 하지만 Visual Basic 이가짂 DB Interfacing 의용이함은 Object Oriented 자체보다근본적으로중요한것이라생각한다

데이터쿼리의갂결화쿼리와데이터벾경작업의통합객체, RDB, XML 데이터의통합 XML 작업의단순화스키마와관계없이 XML 구조파악 XML 문서를빠르게생성 XML 구성요소들에대한쉬운접근 XML is first citizen in VB.net!

Language-INtegrated Query (LINQ) 언어적특징들 (LINQ to Objects) LINQ to Data LINQ to DataSet LINQ to SQL LINQ to Entities LINQ to XML 과 XML 통합

Visual Basic C# Others.NET Language-Integrated Query LINQ enabled data sources LINQ-enabled ADO.NET LINQ To Objects LINQ To Datasets LINQ To SQL LINQ To Entities LINQ To XML <book> <title/> Objects Relational <author/> <price/> </book> XML

Dim highthreadprocs = _ From proc In Process.GetProcesses _ Where proc.threads.count > 10 _ Select proc.processname, proc.threads.count Dim highthreadprocs = Process.GetProcesses(). _ Where(Function(proc As Process) proc.threads.count > 10). _ Select (Function(proc As Process) _ New With {.ProcessName = proc.processname _.Count = proc.threads.count) Function _Filter1(proc As Process) As Boolean Return proc.threads.count > 10 End Function Function _Projection1(proc As Process) As <Anonymous Type> Dim projection As New <AnonymousType> projection.processname = proc.processname projection.count = proc.threads.count Return projection End Function

Project Filter Test Join Group Aggregat e Partition Set Select <expr> Where <expr>, Distinct Any(<expr>), All(<expr>) <expr> Join <expr> On <expr> Equals <expr> Group By <expr>, <expr> Into <expr>, <expr> Group Join <decl> On <expr> Equals <expr> ` Into <expr> Count([<expr>]), Sum(<expr>), Min(<expr>), Max(<expr>), Avg(<expr>) Skip [ While ] <expr>, Take [ While ] <expr> Union, Intersect, Except Order Order By <expr>, <expr> [ Ascending Descending ]

Dim custs() As Customer = SampleData.GetCustomers() Dim q = From c In custs Where c.state = "WA Select c.city Dim q = custs.where(function(c) c.state = WA ).Select(Function(c) c.city) Dim names() As String = q.toarray() custs names ID Name Phone Where Select Function(c) c.state= WA Function(c) c.city

오늘날의쿼리및데이터액세스 Dim c As New SqlConnection( ) c.open() Dim cmd As SqlCommand( _ "SELECT c.name, c.phone & _ "FROM Customers c & _ "WHERE c.city = @p0") cmd.parameters("@p0 ) = "London" Dim dr As DataReader= c.execute(cmd) While (dr.read()) Dim name As String = r.getstring(0) Dim phone As String= r.getstring(1) Dim date As DateTime = r.getdatetime(2) End While r.close() 따옴표로쿼리만들기 Loosely bound arguments Loosely typed result sets 컴파읷할때체크할수없음

LINQ 로데이터액세스 Public Class Customer Public Class Northwind Inherits DataContext Public Property Customers As Table(Of Customer) End Class Dim db As New Northwind( ) Dim contacts = _ From cust in db.customers _ Where cust.city = "London" Select cust.name, cust.phone 데이터를정의한클래스 명확한타입의연결객체 통합된쿼리구문 각테이블은컬렉션으로 For Each custinfo in contacts ColdCall(custInfo.Name, custinfo.phone) 명확한타입 Next 기반의결과

From 이 Select 보다앞선다 읶텔리센스가가능해짂다 Dim customers = _ From cust In db.customers _ Select cust.name, cust.city, cust.state, cust.zip 완벽한조합가능 Dim customers = _ From cust In db.customers _ Select cust.name, cust.city, cust.state, cust.zip _ Order By ZIP _ Select Name, City, State 물롞하나의문장으로도가능 조작은줄단위로이뤄짂다 Dim acustomers = _ From cust In customers _ Where cust.name.startswith( A ) _ Select cust.name, cust.city

명시적읶 Aggregation Grouping key Dim customers = _ From o In Orders _ Group By o.customerid _ Into OrderTotal = Sum(o.Amount * o.price) _ Select CustomerID, OrderTotal 명시적읶 aggregation 계층형데이터를위해연산자를포함한다 그룹이이미졲재 Dim procs= _ From proc In System.Diagnostics.Process.GetProcesses( ) _ Aggregate thread In proc.threads _ Into AvgThreadPriority = Average(thread.CurrentPriority) _ Select Name = proc.processname, AvgThreadPriority

Dim doc As New XmlDocument() Dim contacts As XMLElement = doc.createelement("contacts") For Each Dim c in Customers If (c.country = "USA") Dim e As XMLElement = doc.createelement("contact") Dim name As XMLElement = doc.createelement("name") name.innertext = c.companyname e.appendchild(name) Dim phone As XMLElement = doc.createelement("phone") 명령형모델 phone.innertext = c.phone e.appendchild(phone) contacts.appendchild(e) <contacts> End If <contact> Next <name>great Lakes Food</name> doc.appendchild(contacts) <phone>(503) 555-7123</phone> </contact> </contacts> Document 중심적 통합된쿼리는졲재하지않음 메모리에집중됨

Dim contacts As New XElement("contacts", _ From cust in customers _ Where cust.country = "USA _ Element 중심적 Select New XElement("contact", _ New XElement("name", cust.companyname), _ New XElement("phone", cust.phone) _ ) ) 통합된쿼리 작고가벼움 선언형모델

Only VB!! Dim contacts = _ <contacts> <%= _ From cust In customers _ 직관적 Where cust.country = "USA" _ Select <contact> <name><%= cust.companyname %></name> <phone><%= cust.phone %></phone> </contact> _ %> </contacts> Xml.Linq 의 Xelement 로유추됨 연산결과를채워넣을수있는공갂

객체생성을단순화 Dim emp = _ <employee> <name>joe</name> <age>28</age> <department id="432"> <deptname>engineering</deptname> </department> </employee> Dim emp = _ New XElement("employee", _ New XElement("name", "Joe"), _ New XElement("age", 28), _ New XElement("department", _ New XElement("name", "Engineering"), _ New XAttribute("id", 432)))

모든 Element XML 구성요소들에쉽게접근한다 Dim employees As XElement = GetCurrentEmployeesByDept( IT ) Dim deptid As Integer = CInt(employees.Attribute( DeptID")) Dim emp As XElement = First(employees.Descendents( Employee")) Dim empdob As Date = CDate(item.Element( DateOfBirth ).Value) Attributes Descendents Elements Dim employees As XElement = GetCurrentEmployeesByDept( IT ) Dim deptid As Integer = CInt(employees.@DeptID) Dim emp As XElement = First(employees <Employee>) Dim empdob As Date = CDate(emp.<DateOfBirth>.Value)

XML 을위한 Language integrated query(linq) XPath/XQuery 에서사용되는강력한구문 Visual Basic as programming language! XML 과코드에대한명확한경계가사라짐 DOM 의경험을살리기 Element-centric, not document-centric element/attribute API 들과읷치 Functional construction Text nodes 들은 String! Simplified XML namespace support Faster and smaller than DOM

OOP 에대한이해부족 코드부재로읶한개발생산성저하 리소스부재?

소스벾홖컴포넌트재홗용 Fusion 재개발

PrintForm, Printer Compatibility Library Line and Shape Controls Interop Forms Toolkit 1.0 & 2.0 2.0 includes MDI & user controls

업그레이드젂략 Interop 을통한단계적 Upgrade Form 단위로젂홖, 위험을줄읶다기졲개발된어플리케이션들을 VB.net 으로확장한다 Microsoft Interop Forms Toolkit (v2.0) 업그레이드를이용하게해주는가이드, 도구, 코드제공 코드벾홖기가아님!! VB6 Application VB6 Form(s) Interop (COM) VB.NET Form(s)