Category: Silverlight


Utility

SELECT ‘private ‘ +

CASE data_type

WHEN ‘int’ THEN ‘int’

WHEN ‘bigint’ THEN ‘long’

WHEN ‘binary’ THEN ‘byte[]’

WHEN ‘bit’ THEN ‘bool’

WHEN ‘char’ THEN ‘string’

WHEN ‘date’ THEN ‘DateTime’

WHEN ‘datetime’ THEN ‘DateTime’

WHEN ‘datetime2’ THEN ‘DateTime’

WHEN ‘datetimeoffset’ THEN ‘DateTimeOffset’

WHEN ‘decimal’ THEN ‘decimal’

WHEN ‘float’ THEN ‘float’

WHEN ‘image’ THEN ‘byte[]’

 

WHEN ‘money’ THEN ‘decimal’

WHEN ‘nchar’ THEN ‘string’

WHEN ‘ntext’ THEN ‘string’

WHEN ‘numeric’ THEN ‘decimal’

WHEN ‘nvarchar’ THEN ‘string’

WHEN ‘real’ THEN ‘double’

WHEN ‘smalldatetime’ THEN ‘DateTime’

WHEN ‘smallint’ THEN ‘short’

WHEN ‘smallmoney’ THEN ‘decimal’

WHEN ‘text’ THEN ‘string’

WHEN ‘time’ THEN ‘TimeSpan’

WHEN ‘timestamp’ THEN ‘DateTime’

WHEN ‘tinyint’ THEN ‘int’

WHEN ‘uniqueidentifier’ THEN ‘Guid’

WHEN ‘varbinary’ THEN ‘byte[]’

WHEN ‘varchar’ THEN ‘string’

WHEN ‘nchar’ THEN ‘string’

ELSE ‘CHECK THIS.. ‘ + data_type + ‘ DataType’

END + ‘ ‘+’_’+Lower(COLUMN_NAME) + ‘;’

 

FROM information_schema.columns

WHERE table_name = ‘Your Table Name

 

union all

 

SELECT ‘public virtual ‘ +

CASE data_type

WHEN ‘int’ THEN ‘int’

WHEN ‘bigint’ THEN ‘long’

WHEN ‘binary’ THEN ‘byte[]’

WHEN ‘bit’ THEN ‘bool’

WHEN ‘char’ THEN ‘string’

WHEN ‘date’ THEN ‘DateTime’

WHEN ‘datetime’ THEN ‘DateTime’

WHEN ‘datetime2’ THEN ‘DateTime’

WHEN ‘datetimeoffset’ THEN ‘DateTimeOffset’

WHEN ‘decimal’ THEN ‘decimal’

WHEN ‘float’ THEN ‘float’

WHEN ‘image’ THEN ‘byte[]’

 

WHEN ‘money’ THEN ‘decimal’

WHEN ‘nchar’ THEN ‘string’

WHEN ‘ntext’ THEN ‘string’

WHEN ‘numeric’ THEN ‘decimal’

WHEN ‘nvarchar’ THEN ‘string’

WHEN ‘real’ THEN ‘double’

WHEN ‘smalldatetime’ THEN ‘DateTime’

WHEN ‘smallint’ THEN ‘short’

WHEN ‘smallmoney’ THEN ‘decimal’

WHEN ‘text’ THEN ‘string’

WHEN ‘time’ THEN ‘TimeSpan’

WHEN ‘timestamp’ THEN ‘DateTime’

WHEN ‘tinyint’ THEN ‘int’

WHEN ‘uniqueidentifier’ THEN ‘Guid’

WHEN ‘varbinary’ THEN ‘byte[]’

WHEN ‘varchar’ THEN ‘string’

WHEN ‘nchar’ THEN ‘string’

ELSE ‘CHECK THIS.. ‘ + data_type + ‘ DataType’

END + ‘ ‘ + COLUMN_NAME + char(13)+

‘{

get { return ‘+ ‘_’+ LOWER(COLUMN_NAME)+’; }

set { ‘+’_’+LOWER(COLUMN_NAME)+’ = value; }

}’

 

FROM information_schema.columns

WHERE table_name = ‘Your Table Name

Advertisements

Prism

Prism is a guidance designed and developed by Microsoft which provides a set of libraries consisting of patterns for developing composite applications using Silverlight, WPF and Windows Phone 7. These libraries help in designing and building WPF and Silverlight client applications which are easy and flexible to maintain. The current version of Prism as of this writing is Prism 4.

LINQ

LINQ is an acronym for Language Integrated Query, which is descriptive for where    it’s used and what it does. The Language Integrated part means that LINQ is part    of programming language syntax. In particular, both C# and VB are languages that    ship with .NET and have LINQ capabilities. Another programming language that supports    LINQ is Delphi Prism. The other part of the definition, Query, explains what LINQ    does; LINQ is used for querying data. Notice that I used the generic term “data”    and didn’t indicate what type of data. That’s because LINQ can be used to query    many different types of data, including relational, XML, and even objects. Another    way to describe LINQ is that it is programming language syntax that is used to query    data.

 

Unity Framework

Unity is a lightweight, extensible dependency injection container. It facilitates building loosely coupled applications and provides developers with the following advantages: • Simplified object creation, especially for hierarchical object structures and dependencies • Abstraction of requirements; this allows developers to specify dependencies at run time or in configuration and simplify management of crosscutting concerns • Increased flexibility by deferring component configuration to the container • Service location capability, which allows clients to store or cache the container • Instance and type interception Unity is a general-purpose container for use in any type of Microsoft® .NET Framework-based application. It provides all of the features commonly found in dependency injection mechanisms, including methods to register type mappings and object instances, resolve objects, manage object lifetimes, and inject dependent objects into the parameters of constructors and methods and as the value of properties of objects it resolves. In addition, Unity is extensible. You can write container extensions that change the behavior of the container, or add new capabilities. For example, the interception feature provided by Unity, which you can use to capture calls to objects and add additional functionality and policies to the target objects, is implemented as a container extension.

MVVM

The Model View ViewModel (MVVM) is an architectural pattern used in software  engineering that originated from Microsoft which is specialized in the  Presentation Model design pattern. It is based on the Model-view-controller  pattern (MVC), and is targeted at modern UI development platforms (WPF and  Silverlight) in which there is a UX developer who has different requirements  than a more “traditional” developer. MVVM is a way of creating client  applications that leverages core features of the WPF platform, allows for simple  unit testing of application functionality, and helps developers and designers  work together with less technical difficulties.

VIEW: A View is defined in XAML and should not have any logic in the  code-behind. It binds to the view-model by only using data binding.

MODEL: AModel is responsible for exposing data in a way that is easily consumable  by WPF. It must implement INotifyPropertyChanged and/or INotifyCollectionChanged  as appropriate.

VIEWMODEL: A ViewModel is a model for a view in the application or we can say as  abstraction of the view. It exposes data relevant to the view and exposes the  behaviors for the views, usually with Commands.

MVC 3

I choose to develop my application with the Asp.Net MvC framework because it enables me to develop high quality web applications. The framework utilizes successful design patterns (Model View Controller) and is build using important object oriented principles and best-practices like separation of concerns, loose coupling and testability. While it may take some getting used to for those coming from Asp.Net Web Forms, the initial learning investment will prove worth while.

The Asp.Net MvC framework recently had it’s third major release, while many new features have been added, there are two new features that got me really exited. First is the Razor view engine, which offers cleaner and “easy on the eyes” syntax for the views. Razor comes with full Intellisense support. The second feature is the NuGet package manager which enables developers to easily manage third party libraries and their dependencies from within Visual Studio. NuGet makes installing and updating off all third party libraries a breeze. We will be working with both these new features during this article series. After discussing the framework let’s talk about the application we are going to build.

NHibernate

NHibernate is an ORM, or Object-Relational Mapper. In the same line as LINQ to SQL, Entity Framework, LLBLGen, and others, ORM tools remove most of the need to write stored procedures to handle common data access (CRUD) for your business objects. ORM tools require that you create (either manually or with a visual designer…depends on the one you choose) a mapping specification that traces which properties of your objects map to which columns of your tables and/or views in your database. When you need to retrieve objects, the ORM tool generates the appropriate SQL for you, and sends it to the database. When the time comes to update your objects, the ORM will not only create the SQL to insert, update, and delete for you…it will also batch those commands so that a single connection and batch of commands are sent to the database and performs the whole thing in a transaction. ORM tools can also improve the efficiency of your queries by allowing you to select entire object graphs in a single go, generating the most efficient SQL for the task.

With ORM tools, you still need to query, however you either with basic methods on the ORM’s context or session object, or with a custom query language for that ORM. These days, most ORM’s, including NHibernate, also provide LINQ support, allowing you to use standard LINQ syntax to query your object model, which in turn is translated to SQL queries against your database for you.

The benefit of OR mappers is that you centralize almost ALL of your code into your domain, rather than splitting it between domain and stored procs. You lighten the stored procedure load on your database, providing less of a barrier to refactoring your database if the need ever arises, providing greater business agility not only in your domain, but also with your database schema. Since you don’t have to write SQL, and especially if you use LINQ, you can often create a more efficient application in less effort with lower long term maintenance costs.

Aside from the inevitable war with your DBA’s (if you have them), OR mappers can bring considerable benefits to the table that can reduce implementation effort, improve maintainability, and provide greater business agility.

Windows Communication Foundation (WCF) is an SDK for developing and deploying services on Windows. WCF provides a runtime environment for your services, enabling you to expose CLR types as services, and to consume other services as CLR types. Although in theory you could build services without WCF, in practice building services is significantly easier with WCF. WCF is Microsoft’s implementation of a set of industry standards defining service interactions, type conversion, marshaling, and various protocols’ management. Because of that, WCF provides interoperability between services. WCF provides developers with the essential off-the-shelf plumbing required by almost any application, and as such, it greatly increases productivity. The first release of WCF provides many useful facilities for developing services, such as hosting, service instance management, asynchronous calls, reliability, transaction management, disconnected queued calls, and security. WCF also has an elegant extensibility model that you can use to enrich the basic offering. In fact, WCF itself is written using this extensibility model. The rest of the chapters in this book are dedicated to those aspects and features. Most all of the WCF functionality is included in a single assembly called System.ServiceModel.dll in the System.ServiceModel namespace.

WCF is part of .NET 3.0 and requires .NET 2.0, so it can only run on operation systems that support it. Presently this list consists of Windows Vista (client and server), Windows XP SP2, and Windows Server 2003 SP1 or their later versions.

RIA Services

Microsoft .NET RIA Services simplifies the traditional n-tier application pattern by bringing together the ASP.NET and Silverlight platforms. The RIA Services provides a pattern to write application logic that runs on the mid-tier and controls access to data for queries, changes and custom operations. It also provides end-to-end support for common tasks such as data validation, authentication and roles by integrating with Silverlight components on the client and ASP.NET on the mid-tier.

   Our thinking on the RIA Services work really grow out of the LINQ project a few years ago.  LINQ integrates query semantics into the languages (C#, VB, etc) providing a common abstraction for working with data; whether that data is in memory CLR objects, XML, relational data,  or anything else.   With RIA Services we are extending this pattern by offering a prescriptive model for exposing your domain logic over LINQ. We think of domain logic as that part of your application that is very specific to your domain – that is the particular business problem you are solving.    By following this pattern we are able to provide a number of features that help you focus on your domain logic rather than the plumbing in your code.  For example, we offer a great way to write application logic on the server and display, validate the data,  as well as supporting authorization,  querying, sorting, filtering, paging, etc, not to mention providing a clean way to mock out the data layer to do testing (a la TDD, etc).  All regardless of what data store you use (Entity Framework, Linq2Sql, nHibernate, Xml file, REST service, WCF-server, etc).