Saturday, 20. December 2008, 09:00:38
Muốn trái tim em luôn thuộc về anh
Muốn chúng ta sẽ không rời xa nữa
Muốn những đêm cô đơn chờ anh sẽ hết
Mỗi lúc bên em anh đành câm nín
Đến lúc xa em anh lại rất buồn,
Biết nói sao đây cho thật lòng với chính anh.
Muốn chúng ta bước qua ngày giông tố
Muốn chính anh sẽ mang niềm vui đến
Để thấy em luôn tươi cười như lúc trước
Mỗi lúc bên anh em thường hay khóc,
Nói với anh hãy ở bên em hoài ,
Ôm em ôm thật lòng vì sao mình chia tay
Ngày đó có nhau đâu ngờ ta có lúc phải luôn xa nhau đến thế này ,
Xa em bao nhiêu ngày anh yêu em thêm bấy nhiêu lần ,
Dù biết mất nhau bao ngày sao chỉ có mỗi anh với đêm dài
Dù cho có ra sao , thì anh vẫn yêu em.
Hạnh phúc mãi mãi là điều anh ước muốn ,
Anh mong em hãy hiểu rằng
Xa em bao nhiêu ngày anh luôn không mong thấy em buồn
Dù biết mất nhau bao ngày sao chỉ có mỗi anh với đêm dài ,
Dù cho có ra sao thì anh vẫn yêu em
Mỗi lúc bên em anh đành câm nín
Để thấy em luôn vui cười hạnh phúc
Để lúc xa em anh nói yêu em.
Tại sao mỗi lúc bên em, anh thường câm nín vì anh muốn được nghe tiếng nói của em. Anh muốn được nghe những sở thích, những niềm vui của em. Em có biết là mỗi khi kể chuyện vui của em, em cười trông thấy ghét lắm không? Rồi em nói: "sao anh không nói gì hết vậy, bắt em nói chuyện không hà". Không phải anh không có gì để nói với em mà anh muốn nói với em rất nhiều, rất nhiều. Nhưng những gì anh muốn nói anh không biết diễn đạt bằng lời, anh chỉ nói với em bằng ánh mắt, bằng trái tim, bằng những hành động. Anh cảm thấy thật hạnh phúc khi đem niềm vui đến cho em và anh cảm thấy mình vô dụng khi không sang sẽ được cho em những ưu tư phiền muộn. Anh đã cảm nhận được một ngày không có tiếng nói và tin nhắn của em.
Xin em hãy tin rằng luôn có một người đang mỉm cười khi em hạnh phúc, sẳn sàng chia sẽ khi em buồn, luôn mong em có được những điều tốt đẹp nhất trên đời.
Thursday, 18. December 2008, 06:17:09
Tôi không muốn nghĩ những chuyện buồn,
Tôi không muốn lo lắng nhiều,
Tôi muốn được vui vẻ, được làm những điều mình thích, ...
Nhưng có được đâu...
Cuộc đời luôn đầy dzẫy những chông gai, những vui buồn mà chúng ta không thể tránh được.
Muốn sống tốt chúng ta phải đương đầu với nó cùng nhau vượt qua nó.
Tôi không muốn khóc...
Nhưng nước mắt cứ chảy trong lòng,
Không dâng trào trên nét mặt,
Nhưng đau thương trong lòng.
Tôi muốn có giấc ngủ ngon...
Nhưng làm sao ngủ được,
Mỗi khi nằm xuống thì mọi lo lắng ưu phiền lại đến với tôi,
Khi trong giấc mơ những lo âu lại tìm đến.
Friday, 28. November 2008, 09:29:19
Nếu như là anh em quê hương Bến Tre hãy tham gia vào diễn đàn phổ biến kiến thức tin học cho quê hương Bến Tre nhe. Diễn đàn này do nhóm sinh viên khóa đầu tiên của trường Cao Đẳng Bến Tre thành lập.
Mục đích của diễn đàn mong muốn chia sẽ những hiểu biết, kinh nghiệm trong lĩnh vực công nghệ thông tin cho mọi người, đặc biệt quê hương Bến Tre.
Ai muốn tham gia có thể vào link sau:
http://itbentre.comLogo của diễn đàn:
Mộc của diễn đàn:
Thursday, 16. October 2008, 06:30:47
1.1 What is LINQ?
Language Integrated Query (or LINQ, pronounced “link” for short), is a set of Microsoft® .NET technologies that provide built-in language querying functionality similar to SQL, not only for database access, but for accessing data from any source.
There is no one definition for LINQ, but it aims to solve the problem where we currently use different techniques for manipulating and selecting data from databases versus XML versus object collections; LINQ aims to make our life easier by giving us a coordinated, consistent and efficient syntax from our development environment and by using your one chosen programming language, rather than switching between programming languages.
The current LINQ family of technologies and concepts allows an extensible set of operators that work over objects, SQL data and XML data sources. The generalized architecture of the technology also allows the LINQ concepts to be expanded to almost any data domain or technology, so what LINQ is today will expand in the future.
I think the LINQ Project Overview introduction by Don Box and Anders Hejlsberg is a great starting point -
After two decades, the industry has reached a stable point in the evolution of object-oriented (OO) programming technologies. Programmers now take for granted features like classes, objects, and methods. In looking at the current and next generation of technologies, it has become apparent that the next big challenge in programming technology is to reduce the complexity of accessing and integrating information that is not natively defined using OO technology. The two most common sources of non-OO information are relational databases and XML.
Rather than add relational or XML-specific features to our programming languages and runtime, with the LINQ project we have taken a more general approach and are adding general purpose query facilities to the .NET Framework that apply to all sources of information, not just relational or XML data. This facility is called .NET Language Integrated Query (LINQ).
We use the term language integrated query to indicate that query is an integrated feature of the developer's primary programming languages (e.g., C#, Visual Basic). Language integrated query allows query expressions to benefit from the rich metadata, compile-time syntax checking, static typing and IntelliSense that was previously available only to imperative code. Language integrated query also allows a single general-purpose declarative query facility to be applied to all in-memory information, not just information from external sources.
.NET Language Integrated Query defines a set of general-purpose standard query operators that allow traversal, filter, and projection operations to be expressed in a direct yet declarative way in any .NET-based programming language. The standard query operators allow queries to be applied to any IEnumerable-based information source. LINQ allows third parties to augment the set of standard query operators with new domain-specific operators that are appropriate for the target domain or technology. More importantly, third parties are also free to replace the standard query operators with their own implementations that provide additional services such as remote evaluation, query translation, optimization, etc. By adhering to the conventions of the LINQ pattern, such implementations enjoy the same language integration and tool support as the standard query operators.
The extensibility of the query architecture is used in the LINQ project itself to provide implementations that work over both XML and SQL data. The query operators over XML (XLinq) use an efficient, easy-to-use in-memory XML facility to provide XPath/XQuery functionality in the host programming language. The query operators over relational data (DLinq) build on the integration of SQL-based schema definitions into the CLR type system. This integration provides strong typing over relational data while retaining the expressive power of the relational model and the performance of query evaluation directly in the underlying store.
1.2 LINQ to Objects
LINQ to Objects allows .NET developers to write “queries” over collections of objects.
Traditionally, working with collections of objects meant writing a lot of looping code using for loops or foreach loops to iterate through a list carrying out filtering using if statements, and some action like keeping a running sum of a total property. LINQ frees you from having to write looping code; it allows you to write queries that filter a list or calculate aggregate functions on elements in a collection as a set.
We can write queries against any collection type that implements an interface called IEnumerable (and also a new interface called IQueryable, but more on that later). This is almost any collection type built into the .NET class libraries including simple arrays like string[], or int[], and any List<T> collection we define. Let us look at a few of the simplest examples to understand the basic syntax.
int[] nums = new int[] {0,4,2,6,3,8,3,1};
var result = from n in nums
where n < 5
orderby n
select n;
foreach(int i in result)
Console.WriteLine(i);
Output:
0
1
2
3
3
4
An example of calculating the aggregate sum of all the elements would look like
int[] nums = new int[] {0,4,2,6,3,8,3,1};
int result = nums.Sum();
Console.WriteLine(result);
Output:
27
LINQ to Objects extends any type that inherits from IEnumerable (which is almost every collection class in .NET, from simple Arrays to List<T>) to support query operations similar to those available in SQL. We can write queries using any of the built-in Standard Query Operators, or add our own operators if we need to. The standard operators cover a wide variety of categories, at present there are over fifty that form the backbone of LINQ. To get an idea of their scope, here is a list of those operators available to us
Operator Type
Operator Name
Aggregation
Aggregate, Average, Count, LongCount, Max, Min, Sum
Conversion
Cast, OfType, ToArray, ToDictionary, ToList, ToLookup, ToSequence
Element
DefaultIfEmpty, ElementAt, ElementAtOrDefault, First, FirstOrDefault, Last, LastOrDefault, Single, SingleOrDefault
Equality
EqualAll
Generation
Empty, Range, Repeat
Grouping
GroupBy
Joining
GroupJoin, Join
Ordering
OrderBy, ThenBy, OrderByDescending, ThenByDescending, Reverse
Partitioning
Skip, SkipWhile, Take, TakeWhile
Quantifiers
All, Any, Contains
Restriction
Where
Selection
Select, SelectMany
Set
Concat, Distinct, Except, Intersect, Union
Most of the operators should be familiar if you have ever worked with a relational database writing queries in SQL. One important distinction between writing SQL queries and LINQ queries is that the operator order is reversed. If you are used to Select-From-Where-OrderBy, it might take some time to overcome the muscle memory and move to From-Where-OrderBy-Select.
To demonstrate some of LINQ’s query capabilities let us write a few queries over this data.
Sample Contact data
FirstName
LastName
DayOfBirth
Phone
State
Barney
Gottshall
19-Oct-1945
885 983 8858
CA
Armando
Valdes
9-Dec-1973
848 553 8487
WA
Adam
Gauwain
3-Oct-1959
115 999 1154
AK
Jeffery
Deane
16-Dec-1950
677 602 6774
CA
Collin
Zeeman
10-Feb-1935
603 303 6030
FL
Stewart
Kagel
20-Feb-1950
546 607 5462
WA
Chance
Lard
21-Oct-1951
278 918 2789
WA
Blaine
Reifsteck
18-May-1946
715 920 7157
TX
Mack
Kamph
17-Sep-1977
364 202 3644
TX
Ariel
Hazelgrove
23-May-1922
165 737 1656
OR
List<Contacts> contacts = Contacts.SampleData();
var q = from c in contacts
where c.DateOfBirth.AddYears(35) > DateTime.Now
orderby c.DateOfBirth descending
select c.FirstName + " " + c.LastName +
" b." + c.DateOfBirth.ToString("dd-MMM-yyyy");
foreach(string s in q)
Console.WriteLine(s);
Output:
Mack Kamph b.17-Sep-1977
Armando Valdes b.09-Dec-1973
The previous example demonstrates how to get a list of contacts who are less than 35 years of age sorted in descending order by age. This query builds a list of formatted strings as the result, but any type can be returned, even an anonymous type (a type we haven’t explicitly defined that holds just our data, but more on that later). Figure 6 demonstrates grouping, which allows you to create a sub-collection of elements based on a value by using the group by construct.
List<Contacts> contacts = Contacts.SampleData();
var q = from c in contacts
group c by c.State;
foreach(var group in q) {
Console.WriteLine("State: " + group.Key);
foreach(Contacts c in group)
Console.WriteLine(" {0) {1}", c.FirstName, c.LastName);
}
Output:
State: CA
Barney Gottshall
Jeffery Deane
State: WA
Armando Valdes
Stewart Kagel
Chance Lard
State: AK
Adam Gauwain
State: FL
Collin Zeeman
State: TX
Blaine Reifsteck
Mack Kamph
State: OR
Ariel Hazelgrove
A key aspect of accessing relational data is the concept of joining. SQL languages have powerful join capabilities to allow queries to be written against normalized data which is a fancy term for not repeating data, by separating data across multiple tables linking by a common value. LINQ allows you to join multiple object collections together using syntax similar to SQL. To demonstrate, in addition to the data shown in Sample Contact data, also consider the following call log data.
Sample Call Log data
Number
Duration (mins)
Incoming
Date
Time
885 983 8858
2
TRUE
7-Aug-2006
8:12
165 737 1656
15
TRUE
7-Aug-2006
9:23
364 202 3644
1
FALSE
7-Aug-2006
10:5
603 303 6030
2
FALSE
7-Aug-2006
10:35
546 607 5462
4
TRUE
7-Aug-2006
11:15
885 983 8858
15
FALSE
7-Aug-2006
13:12
885 983 8858
3
TRUE
7-Aug-2006
13:47
546 607 5462
1
FALSE
7-Aug-2006
20:34
546 607 5462
3
FALSE
8-Aug-2006
10:10
603 303 6030
23
FALSE
8-Aug-2006
10:40
848 553 8487
3
FALSE
8-Aug-2006
14:00
848 553 8487
7
TRUE
8-Aug-2006
14:37
278 918 2789
6
TRUE
8-Aug-2006
15:23
364 202 3644
20
TRUE
8-Aug-2006
17:12
To join the call log data and retrieve the contact name that matches the phone number we would use the following query.
List<Contacts> contacts = Contacts.SampleData();
List<CallLog> callLog = CallLog.SampleData();
var q = from call in callLog
join contact in contacts on call.Number equals contact.Phone
select new {contact.FirstName, contact.LastName,
call.When, call.Duration};
foreach(var call in q)
Console.WriteLine(“{0} – {1) {2) ({3}min)”,
call.When.ToString("ddMMM HH:m"),
call.FirstName, call.LastName, call.Duration);
Output:
07Aug 08:12 - Barney Gottshall (2min)
07Aug 09:23 - Ariel Hazelgrove (15min)
07Aug 10:5 - Mack Kamph (1min)
07Aug 10:35 - Collin Zeeman (2min)
07Aug 11:15 - Stewart Kagel (4min)
07Aug 13:12 - Barney Gottshall (15min)
07Aug 13:47 - Barney Gottshall (3min)
07Aug 20:34 - Stewart Kagel (1min)
08Aug 10:10 - Stewart Kagel (3min)
08Aug 10:40 - Collin Zeeman (23min)
08Aug 14:0 - Armando Valdes (3min)
08Aug 14:37 - Armando Valdes (7min)
08Aug 15:23 - Chance Lard (6min)
08Aug 17:12 - Mack Kamph (20min)
This query joins call records with contact data via the phone number.
Going one step further and summarizing data from multiple collections by combining filtering, grouping, joining and aggregate functions all in one query expression, we can demonstrate the power of Query Expressions on in-memory data. The following example show incoming call records from each contact and the aggregate call statistics.
List<Contacts> contacts = Contacts.SampleData();
List<CallLog> callLog = CallLog.SampleData();
var q = from call in callLog
where call.Incoming == true
group call by call.Number into g
join contact in contacts on g.Key equals contact.Phone
orderby contact.FirstName, contact.LastName
select new { contact.FirstName, contact.LastName,
Count = g.Count(),
Avg = g.Average( c => c.Duration ),
Total = g.Sum( c => c.Duration )};
foreach(var call in q)
Console.WriteLine("{0} {1} - Calls:{2}, Time:{3}mins, Avg:{4}mins",
call.FirstName, call.LastName,
call.Count, call.Total, Math.Round(call.Avg, 2));
Output:
Ariel Hazelgrove - Calls:1, Time:15mins, Avg:15mins
Armando Valdes - Calls:1, Time:7mins, Avg:7mins
Barney Gottshall - Calls:2, Time:5mins, Avg:2.5mins
Chance Lard - Calls:1, Time:6mins, Avg:6mins
Mack Kamph - Calls:1, Time:20mins, Avg:20mins
Stewart Kagel - Calls:1, Time:4mins, Avg:4mins
This example shows filtering, ordering, grouping, joining and selection using aggregate values.
Friday, 12. September 2008, 01:19:48
Showing posts 1 -
5 of 32.