It would seem that the following are trivial matters but I found some enlightenment today and I thought I share it with the world.
1. The Date.Today function can be used to find dates in the past and in the future.
Eg: finding what the date is for tomorrow
Tomorrow = Date.Today.AddDays(1.0)
Yesterday = Date.Today.AddDays(-1.0)
There is also the AddTicks, Seconds, Minutes, Days, Months and Years that you can use to get a date in the future or past.
2. The Calendar Extender in AJAX.
I wouldn't want to blog much about this as much has already been said at the location below.
Tone's blog
Thursday, March 26, 2009
Wednesday, March 25, 2009
Designing - A dilemma
Working on a few projects lately got me thinking about design paradigms.
In fact, it got me confused with it for awhile.
Since leaving the safe-haven of education, my designing skills have eroded and it is good to re-acquaint myself with it once again, at least of what I still remember.
At the current moment, I am using the factory pattern with a service layer with an interface join all the different objects. I do, however have the need to access a database, thus that makes the necessity for a repository to be in place.
I wonder if all I do at work is having this design pattern in place. It seems to be the case with all the projects that I stumble across. Is this the industry standard? Thoughts, anyone?
In fact, it got me confused with it for awhile.
Since leaving the safe-haven of education, my designing skills have eroded and it is good to re-acquaint myself with it once again, at least of what I still remember.
At the current moment, I am using the factory pattern with a service layer with an interface join all the different objects. I do, however have the need to access a database, thus that makes the necessity for a repository to be in place.
I wonder if all I do at work is having this design pattern in place. It seems to be the case with all the projects that I stumble across. Is this the industry standard? Thoughts, anyone?
Tuesday, March 24, 2009
LINQ statement similar to SQL "In" statement
This is a very interesting LINQ feature I've stumbled across in my day to day work.
I can't quite post my work here but essentially, it is quite possible to imitate the "IN" statement in SQL.
What I meant by the "IN" query is for example;
SELECT * FROM [table]
WHERE id IN (1, 2, 3)
Using the extension method of "Contains" method, we achieve the SQL "In" method using LINQ. See below.
Have 2 list.
Eg: listOfElements1, listOfElements2
Depending on which list you would like to obtain the information from, perform a LINQ query on that list. For the purpose of this example, I am going to be using the LINQ query on the 1st list of elements.
VB Code
Dim linqToTest = From le1 In listOfElements1.ToArray() _
Where listOfElements2.Contains(le1.[elementName]) _
Select le1
A point to note is that 1 of my list is a list of primitive variables (listOfElements2) and the other (listOfElements1) is a list of objects.
Should you require joining of 2 list of similar types, primitive variables list with primitive variables list of the same type or list of objects that have 1 similar property, the LINQ "intersect" function should suffice.
References:
1. Rob Conery's blog; Wekeroad
I can't quite post my work here but essentially, it is quite possible to imitate the "IN" statement in SQL.
What I meant by the "IN" query is for example;
SELECT * FROM [table]
WHERE id IN (1, 2, 3)
Using the extension method of "Contains" method, we achieve the SQL "In" method using LINQ. See below.
Have 2 list.
Eg: listOfElements1, listOfElements2
Depending on which list you would like to obtain the information from, perform a LINQ query on that list. For the purpose of this example, I am going to be using the LINQ query on the 1st list of elements.
VB Code
Dim linqToTest = From le1 In listOfElements1.ToArray() _
Where listOfElements2.Contains(le1.[elementName]) _
Select le1
A point to note is that 1 of my list is a list of primitive variables (listOfElements2) and the other (listOfElements1) is a list of objects.
Should you require joining of 2 list of similar types, primitive variables list with primitive variables list of the same type or list of objects that have 1 similar property, the LINQ "intersect" function should suffice.
References:
1. Rob Conery's blog; Wekeroad
Subscribe to:
Posts (Atom)