.NET Framework 4.0 Statistics … This is interesting

I’ve often found it’s hard to know all that the framework has to offer.  I’m left wondering I wonder where I can look to find somthing like that. I’ve also found it’s hard to get a complete 10,000 foot view of the entire framework. I think I know some reasons why now… It’s ginormious.  Check out the stats from Scott Dorman’s blog.

http://geekswithblogs.net/sdorman/archive/2010/07/10/interesting-.net-framework-4-statistics.aspx

There were a total of 44,346 types (loaded from 130 assemblies), with 33,152 classes, 2,398 interfaces, 4,828 enums, and 8,796 value types. The complete breakdown is shown below.

Of the 33,152 classes, 564 of them are exceptions. There are 428 public and 136 non-public exceptions. The complete breakdown is shown below.

Exam 70-515: TS: Web Applications Development with Microsoft .NET Framework 4 prep

Exam 70-515:

TS: Web Applications Development with Microsoft .NET Framework 4

I hope I’m not the only one that was disappointed to see that the release for the study guide for the 70-515 Web App Development has been pushed back.  I believe on Amazon the date is as late as December 30th! A couple months ago the release was scheduled for November 15th.  I recently finished my Masters Degree, and my brain is turning to mush, and this was my next challenge.

Well, here are a few things I’ll be reviewing until the book is released, hope they help someone else too.

From Microsofts Learning page, the exam is explain as follows.

About this Exam

This exam is designed to test the candidate’s knowledge and skills for developing Web applications using ASP.NET and the .NET Framework 4.
Questions that contain code will be presented in either VB or C#.  Candidates can select one of these languages when they start the exam.

Audience Profile

Candidates for this exam are professional Web developers who use Microsoft Visual Studio. Candidates should have a minimum of two to three years of experience developing Web-based applications by using Visual Studio and Microsoft ASP.NET. Candidates should be experienced users of Visual Studio 2008 and later releases and should have a fundamental knowledge of the .NET Framework 4 programming languages (C# or Microsoft Visual Basic). In addition, candidates should understand how to use the new features of Visual Studio 2010 and the .NET Framework 4.
Candidates should also have a minimum of one year of experience with the following:
  • Accessing data by using Microsoft ADO.NET and LINQ
  • Creating and consuming Web and Windows Communication Foundation (WCF) services
  • State management
  • ASP.NET configuration
  • Debugging and deployment
  • Application and page life-cycle management
  • Security aspects such as authentication and authorization
  • Client-side scripting languages
  • Internet Information Server (IIS)
  • ASP.NET MVC

Credit Toward Certification

When you pass Exam 70-515: TS: Web Applications Development with Microsoft .NET Framework 4, you complete the requirements for the following certification(s):

  • MCTS: .NET Framework 4, Web Applications

Exam 70-515: TS: Web Applications Development with Microsoft .NET Framework 4: counts as credit toward the following certification(s):

  • MCPD: Web Developer 4

Skills Being Measured

This exam measures your ability to accomplish the technical tasks listed below.The percentages indicate the relative weight of each major topic area on the exam.

Developing Web Forms Pages (19%)

  • Configure Web Forms pages.

    This objective may include but is not limited to: page directives such as ViewState, request validation, event validation, MasterPageFile; ClientIDMode; using web.config; setting the html doctype

    This objective does not include: referencing a master page; adding a title to a Web form

  • Implement master pages and themes.

    This objective may include but is not limited to: creating and applying themes; adding multiple content placeholders; nested master pages; control skins; passing messages between master pages; switching between themes at runtime; loading themes at run time; applying a validation schema

    This objective does not include: creating a master page; basic content pages

  • Implement globalization.
    This objective may include but is not limited to: resource files, browser files, CurrentCulture, currentUICulture, ASP:Localize
  • Handle page life cycle events.
    This objective may include but is not limited to: IsPostback, IsValid, dynamically creating controls, control availability within the page life cycle, accessing control values on postback, overriding page events
  • Implement caching.
    This objective may include but is not limited to: data caching; page output caching; control output caching; cache dependencies; setting cache lifetimes; substitution control
    This objective does not include: distributed caching (Velocity)
  • Manage state.
    This objective may include but is not limited to: server-side technologies, for example, session and application; client-side technologies, for example, cookies and ViewState; configuring session state (in proc, state server, Microsoft SQL Server; cookieless); session state compression; persisting data by using ViewState; compressing ViewState; moving ViewState

Developing and Using Web Forms Controls (18%)

  • Validate user input.

    This objective may include but is not limited to: client side, server side, and via AJAX; custom validation controls; regex validation; validation groups; datatype check; jQuery validation

    This objective does not include: RangeValidator and RequiredValidator

  • Create page layout.

    This objective may include but is not limited to: AssociatedControlID; Web parts; navigation controls; FileUpload controls

    This objective does not include:  label; placeholder, panel controls; CSS, HTML, referencing CSS files, inlining

  • Implement user controls.
    This objective may include but is not limited to: registering a control; adding a user control; referencing a user control; dynamically loading a user control; custom event; custom properties; setting toolbox visibility
  • Implement server controls.

    This objective may include but is not limited to: composite controls, INamingContainer, adding a server control to the toolbox, global assembly cache, creating a custom control event, globally registering from web.config; TypeConverters

    This objective does not include: postback data handler, custom databound controls, templated control

  • Manipulate user interface controls from code-behind.

    This objective may include but is not limited to: HTML encoding to avoid cross-site scripting, navigating through and manipulating the control hierarchy; FindControl; controlRenderingCompatibilityVersion; URL encoding; RenderOuterTable

    This objective does not include: Visibility, Text, Enabled properties

Implementing Client-Side Scripting and AJAX (16%)

  • Add dynamic features to a page by using JavaScript.
    This objective may include but is not limited to: referencing c
    lient ID; Script Manager; Script combining; Page.clientscript.registerclientscriptblock; Page.clientscript.registerclientscriptinclude; sys.require (scriptloader)
    This objective does not include: interacting with the server; referencing JavaScript files; inlining JavaScript
  • Alter a page dynamically by manipulating the DOM.

    This objective may include but is not limited to: using jQuery, adding, modifying, or removing page elements, adding effects, jQuery selectors

    This objective does not include: AJAX

  • Handle JavaScript events.
    This objective may include but is not limited to: DOM events, custom events, handling events by using jQuery
  • Implement ASP.NET AJAX.

    This objective may include but is not limited to: client-side templating, creating a script service, extenders (ASP.NET AJAX Control Toolkit), interacting with the server, Microsoft AJAX Client Library, custom extenders; multiple update panels; triggers; UpdatePanel.UpdateMode; Timer

    This objective does not include: basic update panel and progress

  • Implement AJAX by using jQuery.

    This objective may include but is not limited to: $.get, $.post, $.getJSON, $.ajax, xml, html, JavaScript Object Notation (JSON), handling return types

    This objective does not include: creating a service

Configuring and Extending a Web Application (15%)

  • Configure authentication and authorization.

    This objective may include but is not limited to: using membership, using login controls, roles, location element, protecting an area of a site or a page

    This objective does not include:  Windows Live; Microsoft Passport; Windows and Forms authentication

  • Configure providers.

    This objective may include but is not limited to: role, membership, personalization, aspnet_regsql.exe

    This objective does not include: creating custom providers

  • Create and configure HttpHandlers and HttpModules.
    This objective may include but is not limited to: generic handlers, asynchronous handlers, setting MIME types and other content headers, wiring modules to application events
  • Configure initialization and error handling.
    This objective may include but is not limited to: handling Application_Start, Session_Start, and Application_BeginRequest in global.asax, capturing unhandled exceptions, custom error section of web.config, redirecting to an error page; try and catch; creating custom exceptions
  • Reference and configure ASMX and WCF services.

    This objective may include but is not limited to: adding service reference, adding Web reference, changing endpoints, wsdl.exe, svcutil.exe; updating service URL; shared WCF contracts assembly

    This objective does not include: creating WCF and ASMX services

  • Configure projects and solutions, and reference assemblies.
    This objective may include but is not limited to: local assemblies, shared assemblies (global assembly cache), Web application projects, solutions, settings file, configuring a Web application by using web.config or multiple .config files; assemblyinfo
  • Debug a Web application.
    This objective may include but is not limited to: remote, local, JavaScript debugging, attaching to process, logging and tracing, using local IIS, aspnet_regiis.exe
  • Deploy a Web application.

    This objective may include but is not limited to: pre-compilation, publishing methods (e.g.,
    MSDeploy, xcopy, and FTP), deploying an MVC application

    This objective does not include: application pools, IIS configuration

Displaying and Manipulating Data (19%)

  • Implement data-bound controls.

    This objective may include but is not limited to: advanced customization of DataList, Repeater, ListView, FormsView, DetailsView, TreeView, DataPager, Chart, GridView

    This objective does not include: working in Design mode

  • Implement DataSource controls.

    This objective may include but is not limited to: ObjectDataSource, LinqDataSource, XmlDataSource, SqlDataSource, QueryExtender, EntityDataSource

    This objective does not include: AccessDataSource, SiteMapDataSource

  • Query and manipulate data by using LINQ.

    This objective may include but is not limited to: transforming data by using LINQ to create XML or JSON, LINQ to SQL, LINQ to Entities, LINQ to objects, managing DataContext lifetime

    This objective does not include: basic LINQ to SQL

  • Create and consume a data service.
    This objective may include but is not limited to: WCF, Web service; server to server calls; JSON serialization, XML serialization

    This objective does not include: client side, ADO.NET Data Services

  • Create and configure a Dynamic Data project.
    This objective may include but is not limited to: dynamic data controls, custom field templates; connecting to DataContext and ObjectContext

Developing a Web Application by Using ASP.NET MVC 2 (13%)

  • Create custom routes.
    This objective may include but is not limited to: route constraints, route defaults, ignore routes, custom route parameters
  • Create controllers and actions.
    This objective may include but is not limited to: Visual Studio support for right-click context menus; action filters (including Authorize, AcceptVerbs, and custom) and model binders; ActionResult sub-classes
  • Structure an ASP.NET MVC application.
    This objective may include but is not limited to: single project areas (for example, route registration, Visual Studio tooling, and inter-area links); organizing controllers into areas; shared views; content files and folders
  • Create and customize views.

    This objective may include but is not limited to: built-in and custom HTML helpers (for example, HTML.RenderAction and HTML.RenderPartial), strongly typed views, static page checking, templated input helpers, ViewMasterPage, ViewUserControl

    This objective does not include: Microsoft.Web.Mvc Futures assembly

Entity Framework Load Related Singleton Reference, Delete

1. Simple Load and Bind Example

[sourcecode language=”vb.net”]
Dim AdventureWorks_DataEntity as New AdventureWorksDataEntities()
Dim Query = From e IN AdventureWorks_DataEntity.Employee
Gridview.DataSource = query
Gridview.databind()
[/sourcecode]

2. Load Related Data in Entity Framework

[sourcecode language=”vb.net”]
Dim AdventureWorks_DataEntity as New AdventureWorksDataEntities()
For Each employee in AdventureWorks_DataEntity.Employee
Dim Li as New ListItem()
Li.Text = employee.EmployeeID & ” ”

If (Not employee.EmployeePayHistory.IsLoaded) Then
employee.EmployeePayHistory.Load()
End if

For Each pay In employee.EmployeePayHistory
li.Text &= “Pay Rate: ” & pay.Rate & ” ”
Next pay

BulletedList1.Items.Add(li)
Next employee
[/sourcecode]

Another option for loading related data is to use the “include”. This will eager load the children EmployeePayHistory for the employees.
[sourcecode language=”vb.net”]
Dim AdventureWorks_DataEntity as New AdventureWorksDataEntities()
Dim query = from e in employee.Include(“EmployeePayHistory”)
[/sourcecode]

3. Singleton Reference (One to One) to get relationship use “objectReference”

[sourcecode language=”vb.net”]
var personTwo = (from p in context.Person WHERE p.Student != null select p).first();
personTwo.StudentReference.Load()

‘(one to Many relationship)
personTwo.Student.Load()
[/sourcecode]

4. Delete Entity

[sourcecode language=”C#”]
try
{
using (var context = new AdventureWorks2008Entities())
{
var prod = context.Products.Where(p => p.ProductID == 1005).First();
context.DeleteObject(prod);
context.SaveChanges();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.InnerException.Message);
}

[/sourcecode]

5.ATTACHING and DETACHING

If calls across assembly layer, it’s detached when accessed.

<asp:EntityDataSource Include=”Student”>

<asp:listview Id=”listView” runat=”server” DataKeyNames=”PersonID” DataSourceID=”personDataSource” Insert …

<%# Eval(“Student.Year”) %>

<asp:ObjectDataSource (Develop new class i.e. people.cs as partial class)

SchoolEntities context = new SchoolEntities();

return context.Person.INclude(“Student.Where(p => p.enrollmentdate.hasvalue.tolist();

6.POCO

Still to come…

Variable Scope

Variable Scope

The Scope or Accessibility of a variable depends on where it can be called in an application, and what the lifetime in memory the variable has. This also determines what context the method can be called. The following are defining terms for scope variables.

Scope Terms

Public: Anywhere in or outside of a project

Private: Only in the block where defined

Protected: Can be used in the class where defined. Can also be used within any inherited classes.

Friend: Can only be accessed in code in the same project or assembly
ProtectedFriend: Combination of Protected and Friend

Scope Rules
There are four levels that variables can be declared in an application.

1.Block:  i.e. within an if statement, the variable lifetime ends at the end of the block

2.Procedure: i.e. within a method, outside of an if statement

3.Class: i.e. within a class the lifetime ends when the object is cleaned by the garbage collector

4.Project: i.e. Public variables within module statements, lifetime is until the program ends

Procedure Modifiers

Public: Can be called from anywhere in a project

Private: Can only be called within the class it is declared
Protected: Can only be in the same class from the same class or inherited classes

Friend: Can be called from any code in the same project or assembly

ProtectedFriend: Can be called from in its defined, derived, or procedures in the same project/assembly

Static Variables

Shadowing

Reference: http://msdn.microsoft.com/en-us/library/ms973875.aspx

Eager Loading in Entity Framework

Entity Framework (EF) does not support lazy loading. You must explicitly load the comments advising the EF what to include.

Using ctx as new MyDataContext()

lvComments.DataSource = ctx.Entity.Include(“SomethingToInclude”).First().Comments
lvComments.Databind()

End Using

Or

Using ctx as new MyDataContext()

Dim MyListOfSomething as List(of ListOfSomething) = ctx.ListOfSomething
MyListOfSomething.SomethingToLoad.Load()
lvComments.DataSource = MyListOfSomething.Comments
lvComments.DataBind()

End Using