intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Chuyên đề phát triển phần mềm LINQ remoting

Chia sẻ: 4 4 | Ngày: | Loại File: PDF | Số trang:77

51
lượt xem
6
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Tham khảo sách 'chuyên đề phát triển phần mềm linq remoting', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả

Chủ đề:
Lưu

Nội dung Text: Chuyên đề phát triển phần mềm LINQ remoting

  1. Week 4: LINQ • Basic concepts – LINQ requirements – Concepts • Types – LINQ to objects – LINQ to SQL – LINQ to Entity – LINQ to XML
  2. 2. New features in langauge • Generics • Implicitly Typed Variables • Object Initializers • Anonymous Types • Extension Methods • Lambda Expressions
  3. 2.0 Generics • the creation of various types of collection • type safety • Binary Code Reuse – using System.Collections.Generic;
  4. 2.1 Implicitly Typed Variables • Implicitly Typed Variables – Declare variables without specifying their type – Strongly type, not variant, not object – VS will determinr type • Predict what the compiler will choose • Intellisense support – Type inference -> most general • “3/10/2010” -> string, not date
  5. 2.1 Implicitly Typed Variables • Example var x = new OledbConnection();
  6. 2.1 Implicitly Typed Variables • Note – Alwayls declare the type if we know – Implicitly Typed Variables are suited for LINQ and anonymous type
  7. 2.2 Object Initializers • Constructor • Allow to assign values to object properties (fields) when create object • We do not have to explicitly invoke a constructor • Usefull in any context – Especially userfull in LINQ expressions
  8. 2.2 Object Initializers • Example
  9. 2.3 Anonymous Types • Implicitly type functionality for objects – Set property values to object without writing class definition – The resulting class has no usable name – Class name is generated by compiler, inherits from Object – The result: an anonymous type that is not available at source code level • Also called Projections
  10. 2.3 Anonymous Types • When to user anonymous types – Need a temporary object to hold related data – Don’t need method – If we need a different set of properties for each declaration – If we need to change the order of properties for each declaration
  11. 2.3 Anonymous Types • When not to user anonymous types – Need to define methods – Need to define another variable – Need to shared data across methods
  12. 2.4 Extension Methods • Special kind of Static method • Allow the addition of methods to an existing class – Without creating a new derived type – Without re-compiling or modifying the original type • Called The Same way regular methods are called • Define in static class
  13. 2.4 Extension Methods • Example
  14. 2.4 Extension Methods • Example
  15. 2.4.a Delegate • Delegate – refers to method. – When initialize a delegate, we initialize it with method.
  16. 2.4.a delegate: example
  17. 2.4.a delegate: why
  18. 2.4.a delegate: why
  19. 2.4.a delegate: with anonymous
  20. 2.4.a delegate: with anonymous: return to example
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2