Monday, July 26, 2010

Visual Studio 2010 - Windows Phone 7 Development - Quick and Easy

Well well well, Windows Phone 7.  Hmmmmm.  What to expect.  Interestingly enough, a very big surprise.  The ease of development for Windows Phone 7 is far better than I have seen in the past, especially with the setup and the emulators.  Aside from the extremely long SDK installation, the integration of the SDK into Visual Studio 2010's IDE was worth the wait.  The design time components are drag and drop and fully functional with Silverlight.  Overall very nice!!!!

The design time IDE looks like this:


To much of a surprise to me, I was able to code a very simple lint brush application which I plan to publish on the Market Place once the application is approved very quickly.



The end result from my perspective is that Windows Phone 7 from the SDK and Visual Studio 2010 integration standpoint seem very promising. 

Nice!!!!!!

Wednesday, July 21, 2010

Visual Studio 2010 - AutoMapper, MVC 2 Entity Framework, ASP.NET 4.0

Very nice articles on Auto Mapping one set of objects to another.  An example would be if you have EF objects that you want to map differently for independent views within MVC.

http://www.codeproject.com/Articles/50387/ASP-NET-MVC-ViewModel-Value-Formatting-using-AutoM.aspx

http://automapper.codeplex.com/wikipage?title=Getting%20Started&referringTitle=Home

http://perseus.franklins.net/dnrtvplayer/player.aspx?ShowNum=0155

Tuesday, July 20, 2010

Nice Guide on How to Configure IIS for Silverlight

http://learn.iis.net/page.aspx/262/configuring-iis-for-silverlight-applications/

Friday, June 4, 2010

ADO.NET Entity Framework 4.0 - Does it work??? – Yes it does and below is an example in 6 easy steps.

The first question I had with the entity framework is if the framework actually worked.  As many of us already use tools such as SubSonic, NHibernate, etc, we often question if the ADO.NET Entity Framework 4.0 will provide the same coding benefits as the other tools.  To make the blog entry brief, the answer is yes.  In fact, Microsoft .NET’s ADO.NET Entity Framework 4.0 exceeded my expectation in several areas where the other products either required some additional configuration or code to handle the same simple tasks.

6 Steps to using the Entity Framework based on an already existing database design

Step 1:  

Create a Database (EntityTestDB).  Then add a few tables such as Users, Roles and Profiles.  Link the tables accordingly so that you build a relationship between the User, Role and Profile tables.



 










Step 2:  

Create a New Web Project using Visual Studio 2010.  (For this example, select the MVC 2 Template project).  Once the project is created, Add a new folder called Business Layer with a Business Layer class in that folder.



















Step 3: 

After creating the base project and Web Solution you are now ready to use the ADO.NET Entity Framework.  To do so, right click on the solution and click “Add New Item”.  Click on the “Data Template” Item on the left and then select “ADO.NET Entity Data Model”.  For this Step Name your Entity “EntityTest” and click “Add”.


At this point a wizard will be shown with a number of automated steps to assist you with creating the necessary items for your project.
  • First will be to choose the model contents.  For our example we are going to use the database we created in the first step so select “Generate from Database” and click “Next”.

    • Next either create a new connection or connect to the location where you created your database in Step 1. Then proceed to the next step in the Wizard. (You can leave the default checkboxes for this step.)

    • Next you are going to choose what objects you would like for your Model.  For our example select them all and click “Finish”.  “Tables, Views, and Stored Procedures”.  (You can leave the default checkboxes for this step.)


    • When the Wizard finishes you will be presented with a Model View of your tables. 

    At this point there are several items to be aware of that are very valuable.  First is the Table Mapping Details. (Just “Right Click” on the Model Object and Select “Table Mapping”)













    The second is the Mapping Details for your Operations such as Insert, Update, and Delete.  (Just click on the other icon on the left in the Window showing the Mapping Details.












    Step 4:

    Create a Select Function and map this to the stored procedure we created in Step 1 to retrieve the User, Profile and Role data from the database.  A quick way to perform this step is to use the Entity Model Browser.  To view the Entity Model Browser “Click on View” from the menu bar, then Other Windows, then “Entity Model Browser”.  



    Note: 
    The entity browser will only show you your entity details if you have selected the entity model from Solution Explorer.

    Next you will Navigate in the Entity Model Browser to the “Stored Procedures” section.  Then expand that window and “Right Click” on the stored procedure to select the User, Role and Profile information.  Then click on “Add Function Import”.












    For our example we would like to return a list of Users so when the Wizard starts, make sure to select the User entity as the return type and click “OK”.





























    Step 5:

    Now we are ready to use our Entities, Models and call our Stored procedure.  Navigate to the Business Layer and create a method named “TestEntityFramework” in the class.

    Note:
    For this example it does not matter what is returns or anything we are just showing the functionality.  If you like you can add a grid to the screen and bind the return data to the screen.

    Add the following code to the sample:

















    Step 6:

    From your sample make a call to the “TestEntityFramework” method and view the results.

    SUMMARY

    In summary, Microsoft’s Entity Framework 4.0, the Entity Model Browser and the overall functionality seems to be on par if not better than the other tools that have been used in the past.  The advantages that I noticed were the ability to easily configure the entity framework for LINQ to SQL, Stored Procedures, etc.  In addition, the relational database mapping of the objects is awesome.  There are many more reasons to use this over other tools, and this was more of a tutorial on how to use the ADO.NET Entity Framework 4.0 in Visual Studio 2010 then an evaluation of one tool-set over another.

    Enjoy!!!!

    Wednesday, May 12, 2010

    .NET 4.0 "dynamic" keyword versus, "var" keyword - anonymous types

    The "dynamic" keyword in .NET 4.0.

    What is really cool about this keyword is that the actual type attached to your variables is applied at run-time without needing to worry about properties, methods, etc.  Very cool.  Below will be an explanation of this in a little more detail.


    The "var" keyword
    First you may think that this is just another way to implement the "var" keyword, but this is not true.  The "var" keyword is very different then the "dynamic" keyword.  The "var" keyword does not have the ability to be passed as a parameter to a method or as a return type.

    Now one could argue that you can do this by boxing or why you would want to do this in the first place, but this is purely just to show the differences.  In addition, the "var" keyword is strictly typed so when the compiler reaches this line of code it will perform the proper type casting for you and determine if the expression is correct.

    For example the following line of code will show a compile error as highlighted in red:















    Because the compiler is strictly typing this anonymous type it determines that the method does not exist and causes an error when trying to compile.  Now you can get around this by using reflection or an object, but for this example it is just to show the differences, not so much how to make another way work or not work.

    Now let's take a look at the "dynamic" keyword. 

    For this example we will take the same example as above and see if this compiles using a dynamic anonymous type.  Furthermore, we will even call a method that we know does not exist in the class.















    As you can see with this example the compiler does not check this anonymous type at all or the properties or methods to see if they exist.  It will however dynamically type cast this at run-time.

    Summary
    In summary, the "var" keyword is an anonymous type and will always be derived from the base object class directly.  Whereas, the "dynamic" type will be handled at run-time allowing for more flexibility at the cost of intellisense.

    With all that said, this could be looked at as very dangerous coding.  However, when using objects that are dynamic this could be very handy if used properly.  I could think of a few areas to use this, such as with Web Services where you do not have the WSDL yet, but would like to complete the coding, or legacy COM objects where the properties are dynamic themselves.

    I plan to perform some benchmark tests to see if using this has performance impacts and will update my blog when finished.

    All comments are welcome.

    Tuesday, May 11, 2010

    TFS 2010 server licensing: It's included in MSDN subscriptions

    Very good news for the development community. It appears as though Team Foundation Server and Team System are now included with an MSDN subscription. Great information can be found from the MSDN blog site.

    TFS 2010 server licensing: It's included in MSDN subscriptions


    Cited from "Buck Hodges" blog on MSDN.