Monday, March 27, 2017

MVVMHelpers

Project Description
MvvmHelpers is a cross-platform library for creating applications using the Model-View-ViewModel pattern which was popularized by the XAML frameworks. 

The library supports:
  • .NET 4.5
  • Mono 4.5
  • Windows Store Apps (WinRT)
  • Windows Phone Apps (WinPRT)
  • Xamarin.iOS
  • Xamarin.Android

There are several examples available at http://www.julmar.com/blog/mark?cat=8 where I've been blogging on how to use this library. I'll push some of that information up here as well.

You can install MvvmHelpers through NuGet http://www.nuget.org - just search for MVVMHelpers.PCL, it will add the latest version into your project automatically from within Visual Studio if you install the NuGet plug-in.

Alternatively, you can type the following into the Package Manager console to add it to your project:

PM> Install-Package MVVMHelpers.PCL

Quelle::
http://mvvmhelpers.codeplex.com/

Telerik UI for ASP.NET MVC


Telerik UI for ASP.NET MVC is a set of server-side wrappers that allows using the Kendo UI widgets from C# or VB.NET code.
This article shows how to download Telerik UI for ASP.NET MVC, install it and then run a sample ASP.NET MVC application.
Telerik UI for ASP.NET MVC requires ASP.NET MVC.
The offline sample application requires:
  • LocalDB
Telerik UI for ASP.NET MVC supports:
Telerik UI for ASP.NET MVC Visual Studio Extensions support Visual Studio 2010 and later.
Below are the basic steps for you to follow when downloading Telerik UI for ASP.NET MVC.
Step 1 Log in to your Telerik account.
Step 2 Click Products & Subscriptions in the top navigation.
Step 3 Click UI for ASP.NET MVC. If this option is not available, click one of the following: DevCraft UI EditionDevCraft Complete or DevCraft Ultimate.
Step 4 Click Download Installer and other resources.
Step 5 Find the UI for ASP.NET MVC item, click Browse all product files, and select to download the Telerik online installer (exe file), the MSI installer file directly, or the .zip file.
Run Telerik UI for ASP.NET MVC installer. The automatic setup will guide you through the rest of the installation. If you chose to download the .zipfile, extract it to a location of your preference.
The setup installs Telerik UI for ASP.NET MVC in C:\Program Files (x86)\Telerik\Telerik UI for ASP.NET MVC<version>.
Telerik UI for ASP.NET MVC contains the following directories:
  • js—These are the minified JavaScript files.
  • styles—The minified CSS files and images used by the themes.
  • src—The complete JavaScript, CSS, and C# source code. Note that this directory is not available in the trial version.
  • spreadsheetTelerik.Web.Spreadsheet assembly and its dependencies from Telerik Document Processing library.
  • wrappers\aspnetmvc\Binaries\MVC3—The assemblies for the ASP.NET MVC 3 applications.
  • wrappers\aspnetmvc\Binaries\MVC4—The assemblies for the ASP.NET MVC 4 applications.
  • wrappers\aspnetmvc\Binaries\MVC5—The assemblies for the ASP.NET MVC 5 applications.
  • wrappers\aspnetmvc\Examples\VS2012—The ASP.NET MVC 4 sample application built with Visual Studio 2012.
  • wrappers\aspnetmvc\Examples\VS2013—The ASP.NET MVC 5 sample application built with Visual Studio 2013.
  • wrappers\aspnetmvc\Examples\VS2015—The ASP.NET MVC 5 sample application built with Visual Studio 2015.
  • wrappers\aspnetmvc\Examples\AspNet.Core—The ASP.NET Core sample application built with Visual Studio 2015.
  • wrappers\aspnetmvc\EditorTemplates—The ready-to-use editor templates based on the Kendo UI widgets.
  • wrappers\aspnetmvc\Scaffolding—The Kendo UI Scaffolder Visual Studio extension. It enables generating the Kendo UI MVC wrapper widgets declarations inside Visual Studio projects and is added in the Kendo UI Q1 2015 release.
Telerik UI for ASP.NET MVC comes with a sample ASP.NET MVC application available in two versions:
  • The ASP.NET MVC 4 application built with Visual Studio 2012.
  • The ASP.NET MVC 5 application built with Visual Studio 2013.
Below are the steps for you to follow when running the sample application.
Step 1 Navigate to the installation directory of Telerik UI for ASP.NET MVC.
Step 2 Open the sample Visual Studio Solution:
  • To run the ASP.NET MVC 4 version, open wrappers\aspnetmvc\Examples\VS2012\Kendo.Mvc.Examples.sln with Visual Studio 2012.
  • To run the ASP.NET MVC 5 version, open wrappers\aspnetmvc\Examples\VS2013\Kendo.Mvc.Examples.sln with Visual Studio 2013.
Step 3 Press CTRL+F5 to build and run the application.
Step 4 A browser loads the start page of the sample application. Use the links to explore the available demos.
Figure 1 The start-up screen of the sample application
 
The sample application Visual Studio solution contains the following:
  • Areas/aspx/Views—WebForm views.
  • Areas/razor/Views—Razor views.
  • Controllers—Controller classes.
  • Models—Model classes.
  • App_Data—LocalDB sample database.
After you run the sample application, read through the following articles, related to Telerik UI for ASP.NET MVC:

 Quelle:
http://docs.telerik.com/kendo-ui/aspnet-mvc/introduction#manually-add-kendo-ui-to-asp.net-mvc-applications

Install Telerik Data Access NuGet packages

Install Telerik Data Access NuGet packages
 
Download Data Access for Free
  • Powerful Runtime Capabilities – inheritance between persistent types, concurrency control mechanisms, key generators, LINQ integration and more
  • Wide variety of supported Relational Database systems ranging from big well known servers to tiny local in-process ones
  • Artificial Types – define persistent types during runtime and use them along with your original data model
  • Online and offline profiling for performance tuning

Install Telerik Data Access NuGet packages:
  • Telerik.DataAccess.Profiler – add Profiling capabilities to your application and use Teleril Data Access Profiler for online or offline analysis of your data layer performance
If you prefer to get the last Telerik Data Access version with Visual Designer download Data Access Q1 2015.

MVC3 Vs MVC4 Vs MVC5 Vs MVC6


MVC3 Vs MVC4 Vs MVC5 Vs MVC6

ASP.NET MVC3
  • New Project Templates having support for HTML 5 and CSS 3.
  • Improved Model validation.
  • Razor View Engine introduced with a bundle of new features.
  • Having support for Multiple View Engines i.e. Web Forms view engine, Razor or open source. You can follow here for a detailed comparison on difference between WebForm View Engine and Razor View Engine.
  • Controller improvements like ViewBag dynamic property and ActionResults Types etc. Dynamic property is a new feature introduced in C# 4.0. ViewBag being a dynamic property has an advantage over ViewData that it doesn’t require checking NULL values. For detailed difference between ViewBag and ViewData can be found.
  • Unobtrusive JavaScript approach that actually separates the functionality from presentation layer on a web page.
  • Improved Dependency Injection with new IDependencyResolver.
  • Partial page output caching.
 
ASP.NET MVC 4
  • ASP.NET Web API, a framework that simplifies the creation of HTTP services and serving a wide range of clients. Follow to create your first ASP.NET Web API service.
  • Adaptive rendering and other look-n-feel improvements to Default Project Templates.
  • A truly Empty Project Template.
  • Based on jQuery Mobile, new Mobile Project Template introduced.
  • Support for adding controller to other project folders also.
  • Task Support for Asynchronous Controllers.
  • Support for OAuth and OpenID logins using DotNetOpenAuth library.
  • Support for Windows Azure SDK 1.6 and new releases.

ASP.NET MVC5
  • ASP.NET Identity for authentication and identity management. Thesedays, modern applications are developed for broader range of clients such as web, mobile in mind. Also, users are actively using their social identities from various social channels like facebook, youtube, twitter etc. ASP.NET Identity is a new Membership system to handle authentication and authorization for variety of clients as well as using user’s existing social identities.
  • Authentication Filters for authenticating user by custom or third-party authentication provider.
  • With the help of Filter overrides, we can now override filters on a method or controller.
  • Bootstrap replaced the default MVC template.
  • Attribute Routing is now integrated into MVC5. Basically, MVC Routing is an excellent way to create human friendly and Search Engine Optimized URLs. You can easily get understanding about Routing in ASP.NET MVC here. Attribute based routing enables us to define routes along with

action methods as follows:
  [Route(“Students/{id}”)]
  public ActionResult GetStudentById(string id)
{        
           // code logic here.        
           return View();
}


ASP.NET MVC6 | ASP.NET vNext
  • Single Programming Model for ASP.NET MVC and ASP.NET Web API.
  • Optimized for Cloud Computing.
  • Supporting side by side deployment of runtime and framework along with application.
  • Out of the box support for dependency injection.
  • vNext is Open Source and supports running on multiple platforms including Linux and Mac.
  • New JSON-based project Extension.
  • In order to dynamically compile code, Roslyn compiler is used.
    For details on new features in 
    ASP.NET vNext,



Linq


The shape of the output of a join clause depends on the specific type of join you are performing. The following are three most common join types:
  • Inner join
  • Group join
  • Left outer join


Inner Join
The following example shows a simple inner equijoin. This query produces a flat sequence of "product name / category" pairs. The same category string will appear in multiple elements. If an element from categories has no matching products, that category will not appear in the results.
C#
            var innerJoinQuery =
               
from category in categories
               
join prod in products on category.ID equalsprod.CategoryID
               
select new { ProductName = prod.Name, Category = category.Name }; //produces flat sequence
For more information, see How to: Perform Inner Joins.


Group Join
A join clause with an into expression is called a group join.
C#
            var innerGroupJoinQuery =
               
from category in categories
               
join prod in products on category.ID equals prod.CategoryID into prodGroup
               
select new { CategoryName = category.Name, Products = prodGroup };
A group join produces a hierarchical result sequence, which associates elements in the left source sequence with one or more matching elements in the right side source sequence. A group join has no equivalent in relational terms; it is essentially a sequence of object arrays.
If no elements from the right source sequence are found to match an element in the left source, the join clause will produce an empty array for that item. Therefore, the group join is still basically an inner-equijoin except that the result sequence is organized into groups.
If you just select the results of a group join, you can access the items, but you cannot identify the key that they match on. Therefore, it is generally more useful to select the results of the group join into a new type that also has the key name, as shown in the previous example.
You can also, of course, use the result of a group join as the generator of another subquery:

C#
            var innerGroupJoinQuery2 =
               
from category in categories
               
join prod in products on category.ID equals prod.CategoryID into prodGroup
               
from prod2 in prodGroup
               
where prod2.UnitPrice > 2.50M
               
select prod2;
For more information, see How to: Perform Grouped Joins.


Left Outer Join
In a left outer join, all the elements in the left source sequence are returned, even if no matching elements are in the right sequence. To perform a left outer join in LINQ, use the DefaultIfEmpty method in combination with a group join to specify a default right-side element to produce if a left-side element has no matches. You can use null as the default value for any reference type, or you can specify a user-defined default type. In the following example, a user-defined default type is shown:
C#
            var leftOuterJoinQuery =
               
from category in categories
               
join prod in products on category.ID equals prod.CategoryID into prodGroup
               
from item inprodGroup.DefaultIfEmpty(new Product { Name = String.Empty, CategoryID = 0 })
               
select new { CatName = category.Name, ProdName = item.Name };
For more information, see How to: Perform Left Outer Joins.


The equals operator
A join clause performs an equijoin. In other words, you can only base matches on the equality of two keys. Other types of comparisons such as "greater than" or "not equals" are not supported. To make clear that all joins are equijoins, the join clause uses the equals keyword instead of the ==operator. The equals keyword can only be used in a join clause and it differs from the == operator in one important way. With equals, the left key consumes the outer source sequence, and the right key consumes the inner source. The outer source is only in scope on the left side of equals and the inner source sequence is only in scope on the right side.


Non-Equijoins
You can perform non-equijoins, cross joins, and other custom join operations by using multiple from clauses to introduce new sequences independently into a query. For more information, see How to: Perform Custom Join Operations.


Joins on object collections vs. relational tables
In a LINQ query expression, join operations are performed on object collections. Object collections cannot be "joined" in exactly the same way as two relational tables. In LINQ, explicit join clauses are only required when two source sequences are not tied by any relationship. When working with LINQ to SQL, foreign key tables are represented in the object model as properties of the primary table. For example, in the Northwind database, the Customer table has a foreign key relationship with the Orders table. When you map the tables to the object model, the Customer class has an Orders property that contains the collection of Orders associated with that Customer. In effect, the join has already been done for you.
For more information about querying across related tables in the context of LINQ to SQL, see How to: Map Database Relationships.


Composite Keys
You can test for equality of multiple values by using a composite key. For more information, see How to: Join by Using Composite Keys. Composite keys can be also used in a group clause.

Example
The following example compares the results of an inner join, a group join, and a left outer join on the same data sources by using the same matching keys. Some extra code is added to these examples to clarify the results in the console display.
C#
    classJoinDemonstration
    {
       
#region Data
class Product
        {
           
public string Name { get; set; }
           
public int CategoryID { get; set; }
        }
class Category
        {
           
public string Name { get; set; }
           
public int ID { get; set; }
        }
// Specify the first data source.
        List<Category> categories =
newList<Category>()
        {
           
new Category(){Name="Beverages", ID=001},
           
new Category(){ Name="Condiments", ID=002},
           
new Category(){ Name="Vegetables", ID=003},
           
new Category() {  Name="Grains", ID=004},
           
new Category() {  Name="Fruit", ID=005}           
        };
// Specify the second data source.
        List<Product> products =
newList<Product>()
       {
         
new Product{Name="Cola",  CategoryID=001},
         
new Product{Name="Tea",  CategoryID=001},
         
new Product{Name="Mustard", CategoryID=002},
         
new Product{Name="Pickles", CategoryID=002},
         
new Product{Name="Carrots", CategoryID=003},
         
new Product{Name="Bok Choy", CategoryID=003},
         
new Product{Name="Peaches", CategoryID=005},
         
new Product{Name="Melons", CategoryID=005},
        };
       
#endregion
static void Main(string[] args)
        {
            JoinDemonstration app =
new JoinDemonstration();
app.InnerJoin();
            app.GroupJoin();
            app.GroupInnerJoin();
            app.GroupJoin3();
            app.LeftOuterJoin();
            app.LeftOuterJoin2();
// Keep the console window open in debug mode.
            Console.WriteLine(
"Press any key to exit.");
            Console.ReadKey();
        }
void InnerJoin()
        {
           
// Create the query that selects
           
// a property from each element.
           
var innerJoinQuery =
              
from category in categories
              
join prod in products on category.ID equalsprod.CategoryID
              
select new { Category = category.ID, Product = prod.Name };
Console.WriteLine("InnerJoin:");
           
// Execute the query. Access results
           
// with a simple foreach statement.
           
foreach (var item ininnerJoinQuery)
            {
                Console.WriteLine(
"{0,-10}{1}", item.Product, item.Category);
            }
            Console.WriteLine(
"InnerJoin: {0} items in 1 group.", innerJoinQuery.Count());
            Console.WriteLine(System.Environment.NewLine);
}
void GroupJoin()
        {
           
// This is a demonstration query to show the output
           
// of a "raw" group join. A more typical group join
           
// is shown in the GroupInnerJoin method.
           
var groupJoinQuery =
              
from category in categories
              
join prod in products on category.ID equals prod.CategoryID into prodGroup
              
select prodGroup;
// Store the count of total items (for demonstration only).
           
int totalItems = 0;
Console.WriteLine("Simple GroupJoin:");
// A nested foreach statement is required to access group items.
           
foreach (var prodGrouping ingroupJoinQuery)
            {
                Console.WriteLine(
"Group:");
               
foreach (var item in prodGrouping)
                {
                    totalItems++;
                    Console.WriteLine(
"   {0,-10}{1}", item.Name, item.CategoryID);
                }
            }
            Console.WriteLine(
"Unshaped GroupJoin: {0} items in {1} unnamed groups", totalItems, groupJoinQuery.Count());
            Console.WriteLine(System.Environment.NewLine);
        }
voidGroupInnerJoin()
        {
           
var groupJoinQuery2 =
               
from category in categories
               
orderbycategory.ID
               
join prod in products on category.ID equals prod.CategoryID into prodGroup
               
select new
                {
                    Category = category.Name,
                    Products =
from prod2 in prodGroup
                              
orderbyprod2.Name
                              
select prod2
                };
//Console.WriteLine("GroupInnerJoin:");
           
int totalItems = 0;
Console.WriteLine("GroupInnerJoin:");
           
foreach (var productGroup ingroupJoinQuery2)
            {
                Console.WriteLine(productGroup.Category);
               
foreach (var prodItem inproductGroup.Products)
                {
                    totalItems++;
                    Console.WriteLine(
"  {0,-10} {1}", prodItem.Name, prodItem.CategoryID);
                }
            }
            Console.WriteLine(
"GroupInnerJoin: {0} items in {1} named groups", totalItems, groupJoinQuery2.Count());
            Console.WriteLine(System.Environment.NewLine);
        }
voidGroupJoin3()
        {
var groupJoinQuery3 =
               
from category in categories
               
join product in products on category.ID equals product.CategoryID into prodGroup
               
from prod in prodGroup
               
orderbyprod.CategoryID
               
select new { Category = prod.CategoryID, ProductName = prod.Name };
//Console.WriteLine("GroupInnerJoin:");
           
int totalItems = 0;
Console.WriteLine("GroupJoin3:");
           
foreach (var item ingroupJoinQuery3)
            {
                totalItems++;
                Console.WriteLine(
"   {0}:{1}", item.ProductName, item.Category);
            }
Console.WriteLine("GroupJoin3: {0} items in 1 group", totalItems, groupJoinQuery3.Count());
            Console.WriteLine(System.Environment.NewLine);
        }
voidLeftOuterJoin()
        {
           
// Create the query.
           
var leftOuterQuery =
              
from category in categories
              
join prod in products on category.ID equals prod.CategoryID into prodGroup
              
selectprodGroup.DefaultIfEmpty(new Product() { Name = "Nothing!", CategoryID = category.ID });
// Store the count of total items (for demonstration only).
           
int totalItems = 0;
Console.WriteLine("Left Outer Join:");
// A nested foreach statement  is required to access group items
           
foreach (var prodGrouping inleftOuterQuery)
            {
                Console.WriteLine(
"Group:", prodGrouping.Count());
               
foreach (var item in prodGrouping)
                {
                    totalItems++;
                    Console.WriteLine(
"  {0,-10}{1}", item.Name, item.CategoryID);
                }
            }
            Console.WriteLine(
"LeftOuterJoin: {0} items in {1} groups", totalItems, leftOuterQuery.Count());
            Console.WriteLine(System.Environment.NewLine);
        }
voidLeftOuterJoin2()
        {
           
// Create the query.
           
var leftOuterQuery2 =
              
from category in categories
              
join prod in products on category.ID equals prod.CategoryID into prodGroup
              
from item inprodGroup.DefaultIfEmpty()
              
select new { Name = item == null ? "Nothing!" : item.Name, CategoryID = category.ID };
Console.WriteLine("LeftOuterJoin2: {0} items in 1 group", leftOuterQuery2.Count());
           
// Store the count of total items
           
int totalItems = 0;
Console.WriteLine("Left Outer Join 2:");
// Groups have been flattened.
           
foreach (var item inleftOuterQuery2)
            {
                totalItems++;
                Console.WriteLine(
"{0,-10}{1}", item.Name, item.CategoryID);
            }
            Console.WriteLine(
"LeftOuterJoin2: {0} items in 1 group", totalItems);
        }
    }
   
/*Output:
 
    InnerJoin:
    Cola      1
    Tea       1
    Mustard   2
    Pickles   2
    Carrots   3
    Bok Choy  3
    Peaches   5
    Melons    5
    InnerJoin: 8 items in 1 group.
Unshaped GroupJoin:
    Group:
        Cola      1
        Tea       1
    Group:
        Mustard   2
        Pickles   2
    Group:
        Carrots   3
        Bok Choy  3
    Group:
    Group:
        Peaches   5
        Melons    5
    Unshaped GroupJoin: 8 items in 5 unnamed groups
GroupInnerJoin:
    Beverages
        Cola       1
        Tea        1
    Condiments
        Mustard    2
        Pickles    2
    Vegetables
        Bok Choy   3
        Carrots    3
    Grains
    Fruit
        Melons     5
        Peaches    5
    GroupInnerJoin: 8 items in 5 named groups
GroupJoin3:
        Cola:1
        Tea:1
        Mustard:2
        Pickles:2
        Carrots:3
        Bok Choy:3
        Peaches:5
        Melons:5
    GroupJoin3: 8 items in 1 group
Left Outer Join:
    Group:
        Cola      1
        Tea       1
    Group:
        Mustard   2
        Pickles   2
    Group:
        Carrots   3
        Bok Choy  3
    Group:
        Nothing!  4
    Group:
        Peaches   5
        Melons    5
    LeftOuterJoin: 9 items in 5 groups
LeftOuterJoin2: 9 items in 1 group
    Left Outer Join 2:
    Cola      1
    Tea       1
    Mustard   2
    Pickles   2
    Carrots   3
    Bok Choy  3
    Nothing!  4
    Peaches   5
    Melons    5
    LeftOuterJoin2: 9 items in 1 group
    Press any key to exit.
    */


Remarks
A join clause that is not followed by into is translated into a Join<TOuter, TInner, TKey, TResult> method call. A join clause that is followed by intois translated to a GroupJoin<TOuter, TInner, TKey, TResult> method call.

Quelle::