Monday, April 29, 2013

[Sample Of Apr 26th] Interactive Windows Service

[Sample Of Apr 26th] Interactive Windows Service:

Homepage image
RSS Feed
Sample Download : http://code.msdn.microsoft.com/CSCreateProcessAsUserFromSe-b682134e
The sample demonstrates how to create/launch a process interactively in the session of the logged-on user from a service application written in C#.Net..
image
You can find more code samples that demonstrate the most typical programming scenarios by using Microsoft All-In-One Code Framework Sample Browser or Sample Browser Visual Studio extension. They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about sample updates. If it is the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on Microsoft Showcase, or read the introduction on our homepage http://1code.codeplex.com/.

[Sample Of Apr 25th] Complex Type Objects demo in EF

[Sample Of Apr 25th] Complex Type Objects demo in EF:

Homepage image
RSS Feed
Sample Download : http://code.msdn.microsoft.com/CSEFComplexType-d058a5a3
 The code sample illustrates how to work with the Complex Type which is new in Entity Framework 4.0.  It shows how to add Complex Type  properties to entities, how to map Complex Type properties to table columns, and how to map a Function Import to a Complex Type.
image
You can find more code samples that demonstrate the most typical programming scenarios by using Microsoft All-In-One Code Framework Sample Browser or Sample Browser Visual Studio extension. They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about sample updates. If it is the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on Microsoft Showcase, or read the introduction on our homepage http://1code.codeplex.com/.

[Sample Of Apr 24th]Customize ASP.NET TreeView node as RadioButton

[Sample Of Apr 24th]Customize ASP.NET TreeView node as RadioButton:

Homepage image
RSS Feed
Sample Download : http://code.msdn.microsoft.com/VBASPNETRadioButtonTreeView-8a1b8fe9
The project shows how to simulate a RadioButton Group within the TreeView control to make the user can only select one item from a note tree in ASP.NET.
image
You can find more code samples that demonstrate the most typical programming scenarios by using Microsoft All-In-One Code Framework Sample Browser or Sample Browser Visual Studio extension. They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about sample updates. If it is the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on Microsoft Showcase, or read the introduction on our homepage http://1code.codeplex.com/.

[Sample Of Apr 23rd] Invokes ADO.NET Data Services in .NET

[Sample Of Apr 23rd] Invokes ADO.NET Data Services in .NET:

Homepage image
RSS Feed
Sample Download :
CS Version: http://code.msdn.microsoft.com/CSADONETDataServiceClient-aaeafce9
VB Version: http://code.msdn.microsoft.com/VBADONETDataServiceClient-ff0849a9
The code sample shows how to invoke the ADO.NET Data Services from a .NET application.
image
You can find more code samples that demonstrate the most typical programming scenarios by using Microsoft All-In-One Code Framework Sample Browser or Sample Browser Visual Studio extension. They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about sample updates. If it is the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on Microsoft Showcase, or read the introduction on our homepage http://1code.codeplex.com/.

[Sample Of Apr 22nd] Client templating with jQuery and JSON

[Sample Of Apr 22nd] Client templating with jQuery and JSON:

Homepage image
RSS Feed
Sample Download :  http://code.msdn.microsoft.com/Client-templating-with-0c85db68
This project illustrates how to display a tabular data to users based on some inputs in ASP.NET application. We will see how this can be addressed with JQuery and JSON to build a tabular data display in web page. Here we use JQuery plug-in JTemplate to make it easy.
imageYou can find more code samples that demonstrate the most typical programming scenarios by using Microsoft All-In-One Code Framework Sample Browser or Sample Browser Visual Studio extension. They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about sample updates. If it is the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on Microsoft Showcase, or read the introduction on our homepage http://1code.codeplex.com/.

ASP.NET Interview Questions: - Show Post Cache substitution?

ASP.NET Interview Questions: - Show Post Cache substitution?:
This is one of the asked ASP.Net Interview Questions during the Interview by the Interviewer.
Post cache substitution is used when we want to cache the whole page but also need some dynamic region inside that cached page. Some examples like QuoteoftheDay, RandomPhotos, and AdRotator etc. are examples where we can implement Post Cache Substitution.
Post-cache substitution can be achieved by two means:

Figure: - “Writesubstitution” in action
You can see we have a static function here “GetDateToString()”. We pass the response substitution callback to the “WriteSubstitution” method. So now, when ASP.NET page framework retrieves the cached page, it automatically triggers your callback method to get the dynamic content. It then inserts your content into the cached HTML of the page. Even if your page has not been cached yet (for example, it's being rendered for the first time), ASP.NET still calls your callback in the same way to get the dynamic content. So you create a method that generates some dynamic content, and by doing so you guarantee that your method is always called, and it’s content is never cached.
Ok the above example was by using “WriteSubstitution” now lets try to see how we can do by using “<>” control. You can get the “<>” control from the editor toolbox.
Figure: - Substitution Control
Figure: - Substitution in Action
Below is a sample code that shows how substitution control works. We have ASPX code at the right hand side and class code at the behind code at the left hand side. We need to provide the method name in the “methodname” attribute of the substitution control.
View following video on Web.config transformation in ASP .Net: -

Learn more on ASP.NET interview questions
Regards,
From more on author’s blog related to ASP.NET interview questions click and visit.

SQL Server Interview Question and answers:- Triggers, Instead of triggers, after triggers, inserted and deleted tables?

SQL Server Interview Question and answers:- Triggers, Instead of triggers, after triggers, inserted and deleted tables?:
Triggers are special kind of stored procedure which have logic's.These logics can be executed after or before data modification happens on a table.There are two types of triggers “Instead of triggers" and "After triggers".

Instead of triggers logic executes prior to data modification while after trigger logic executes after data modification.




In what scenarios will you use instead of trigger and after trigger?

You will use "INSTEAD trigger" to take alternative actions before the update happens.

Some of the uses of instead of trigger's are:-
•Reject updates which are not valid.
•Take some alternative action if any error occurs.
•To implement cascading deletes.For instance you want to delete a customer record.But in order to delete the customer record you also have to delete address records. So you can create a instead of trigger which will first delete the address table before executing delete on customer table.

While "AFTER trigger" is useful when you want to execute trigger logic after the data has been updated.

Some uses of after triggers are:-

•For recording Audit trail where you want new and old values to be inserted in to audit table.
•Updating values after the update has happened.For instance in a sales table if number of products and per product is inserted, you can create an after trigger which will calculate the total sales amount using these two values.

What are inserted and deleted tables?

During triggers we sometimes need old and new values.Insert and deleted tables are temporary tables created by SQL server itself which have new and old values.Inserted tables have one record for newly added data and deleted table has one record of the old version of the data.

So for instance let's say we add a new record called as "Shiv". The inserted table will have "Shiv" and deleted table will have nulls because the record did not exist.Now let’s say some user updates "Shiv" to "Raju".Then inserted table will have "Raju" and deleted tables will have "Shiv".

Also watch my most asked SQL Server interview question video on:- What is the difference between clustered and non-clustered indexes?

Taken from the best selling SQL Server interview question book,you can see more about the book by clicking on  SQL Server interview questions book.

What is BI Semantic model (BISM) in SQL Server 2012?

What is BI Semantic model (BISM) in SQL Server 2012?:
Some days back I was installing SQL Server 2012 enterprise service pack 1. During installation when I was running through the setup, it gave me two options (multi-dimensional and tabular) of  how I want to install SQL Server analysis service. Below is the image captured while doing installation.


At the first glance these options are clearly meant to specify how we want the model design for our analysis service.

No the first option i.e. "MultiDimensional" was pretty clear as I have been using them right from SQL server 2005 till today i.e. (Star schema or Snow flake).

After some googling and hunting I came to know about the second option. Let me through some light on the same and then we will conclude what is BISM.

Now over all we have two kinds of database systems, one is OLTP system where the database design thought process is in terms of tables and normalization rules ( 1 normal form , second normal form and third normal form database design ) are followed.

The second kinds of systems are OLAP system's where we mostly design in terms of fact tables and dimension tables. Cube which is a multi-dimensinal view of data is created properly if you design your database as OLAP system.

Sin simple words we need to create a DB with OLAP design to ensure that proper cubes structure is created.

Now some times I will say many times it's really not feasible to create different structure and then create cubes from them. It would be great if SSAS gives us some options where we can do analysis straight from normalized simple tables

For instance take simple end users who use "Power Pivot". It's very difficult for them to make understand OLAP models like dimension and fact tamles. But yes they do understand tables with rows and columns. If you see microsoft excel the format is in terms of table which have rows and columns and these end users are comfortable with a tabular structure.

Below is a simple image of how simple end users visulize data in excel i.e. tabular - rows and columns.


That's where exactly the second option i.e. the "tabular" mode comes in to picture.

So if we put in simple words BISM (Business intelligence semantic model) is a model which tries to serve simple user / programmers who are comfortable with tabular structure and also maintains professional OLAP  models for corporate.

So BISM is a unifying name for both Multi-dimension and tabular models. So if you are personal BI person who loves ADHOC analysis, you can use power pivot or SSAS tabular IDE to do analysis. And if you are person who is working on a corporate project then Multi-dimension model is more scalable and worth looking in to.

Just alast quick note this is also a favorite SQL Server interview question which is making round now a days when SQL Server 2012 topic is discussed.

With all due respect to my publisher Ihave taken the above answer from my book SQL Server interview questions and answers.

You can also see my blog which has some important for SQL Server interview questions on Colaesce.

You can also see my video on Can views be updated (SQL Server interview questions)?



 



















   

C# interview questions and answers: - What is the difference between “==” and .Equals()?

C# interview questions and answers: - What is the difference between “==” and .Equals()?:

When we create any object there are two parts to the object one is the content and the other is reference to that content.

So for example if you create an object as shown in below code:-
  1. “.NET interview questions” is the content.
  2. “o” is the reference to that content.



 “==” compares if the object references are same while “.Equals()” compares if the contents are same.

So if you run the below code both “==” and “.Equals()” returns true because content as well as references are same.


object o = ".NET Interview questions";
object o1 = o;

Console.WriteLine(o == o1);
Console.WriteLine(o.Equals(o1));
Console.ReadLine();

True
True

Now consider the below code where we have same content but they point towards different instances. So if you run the below code both “==”   will return false and “.Equals()”  will return true.


object o = ".NET Interview questions";
object o1 = new string(".NET Interview questions".ToCharArray());

Console.WriteLine(o == o1);
Console.WriteLine(o.Equals(o1));
Console.ReadLine();

False
True

When you are using string data type it always does content comparison. In other words you either use “.Equals()” or “==” it always do content comparison.

Enjoy this awesome youtube play list which covers 12 important .Net and c# interview question videos

You can also refer our blog which has more than 1000 .NET and c# interview questions with answer

Also see the following c# interview question video on Difference between == VS .Equals():-

Codeproject.tv :- Learn SharePoint Step by Step Videos

Codeproject.tv :- Learn SharePoint Step by Step Videos:
Codeproject.com is like a family to me. So when they announced codeproject.tv which is a extension arm ( I hope I am not wrong) of codeproject.com for videos , I was overexcited.

So here are my three videos on Sharepoint 2010. These three videos will help you to get to speed with sharepoint.

Note :- I have a typical Indian accent  and English is my second language. So if my accent hurts your ears , sorry for it.

In the first video I have explained basics like Sharepoint and Sharepoint foundation. This video is a warm-up video where I have talked about benefits of sharepoint and what are the pre-requisites for installing sharepoint.




In the second video I have wasted no time and I started creating a small portal using sharepoint. While creating this portal we will also go through different sharepoint concepts like Webapplications,Site collection,Site , pages and List. While creating the portal we will take help of custom fields and content types to collect end user data.




This third video is an extension of second video. The second video was almost 25 minutes so I broken down the videos in two parts.




This is my first experiment with codeproject.tv and I wish Chris and Sean the best for their new venture.



Visual Studio 2012 Update 2 is here

Visual Studio 2012 Update 2 is here:
We’re excited to announce that today, Visual Studio 2012 Update 2 (VS2012.2) is now available for download.
For an overview of the five areas of investments in VS2012.2 that we made across agile planning, quality enablement, Windows Store development, line-of-business development, and the general developer experience, please visit Soma’s blog. In particular, you can find an outline of the new functionality and issues we’ve fixed in Visual Studio 2012 Update 2 and comprehensive details on the respective blogs below:
If you encounter a bug or an issue, please report it through the Visual Studio, LightSwitch, and Blend Connect sites. As always, we want to hear your suggestions or feature ideas/improvements so please tell us on UserVoice or vote on other user’s suggestions.
Thanks,
The Visual Studio Team

A convention-based data template selector for Windows 8 XAML Store apps

A convention-based data template selector for Windows 8 XAML Store apps:
This article describes how you can use naming conventions to hook a XAML Data Template to a ViewModel or a Model in a Windows 8 Store app. The last couple of years, convention-based coding became more and more popular in the .NET world. The MVC framework was one of the first managed environments where the constituents of an application (in this case Models, Views, and Controllers) were automatically linked to each other based on their name, instead of letting a developer create references and interfaces. The latest version of the Managed Extensibility Framework –a.k.a. MEF- also comes with a convention-based programming model: the RegistrationBuilder and PartBuilder classes provide an alternative for MEF attributes: they let you specify the rules to infer Parts, Imports, and Exports from the names of your classes and properties. Also in the XAML world, convention-based coding is not new. Most of the popular MVVM frameworks rely heavily on naming conventions to link components together. Caliburn.micro has several classes to lookup the View for a ViewModel (and vice-versa) and to generate data bindings solely based on class and property names: ViewLocator, ViewModelLocator, and ViewModelBinder.
This article presents a way to link a XAML DataTemplate in a View to its corresponding Model or ViewModel data context  class. Here are some screenshots of the attached sample project: it shows a FlipView control (with an associated FlipViewIndicator) that has a different type of Model for each item, so each page should look differently:



In ye olde XAML platforms, you could specify the default data template for a class with the DataType property. In Windows 8 Store app XAML, that property is not supported anymore. So when you want an ItemsControl to display a list of objects of different types, you have to use a DataTemplateSelector. I already explained the mechanisms in this blog post.
The following class defines a data template selector that looks up a data template in the app’s resources, based on the name of the data context class. It just adds “Template” to the name of the data context class, so if you want to display an instance of “Person”, you just have to provide a data template with as x:Key “PersonTemplate”:
/// <summary>
/// Convention-based DataTemplate Selector.
/// </summary>
public sealed class DynamicDataTemplateSelector : DataTemplateSelector
{
    protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
    {
        DataTemplate result = null;
        string typeName = item.GetType().Name;

        try
        {
            result = App.Current.Resources[typeName + "Template"] as DataTemplate;
        }
        catch (Exception)
        {
            Debug.Assert(false, string.Format("No data template found to display '{0}' instances.", typeName));
        }

        return result;
    }
}

The try-catch block is necessary because the resource manager throws an exception when a resource is not found.
Here’s how to apply the selector in an ItemsControl. It is declared as a resource:
<Page.Resources>
    <templates:DynamicDataTemplateSelector x:Key="DynamicDataTemplateSelector" />
</Page.Resources>
And then applied to the FlipView:
<FlipView x:Name="TheFlipView"
            ItemsSource="{Binding Models}"
            ItemTemplateSelector="{StaticResource DynamicDataTemplateSelector}" />
Here are some of the data templates from the resource dictionary:
<!-- Biography -->
<DataTemplate x:Key="BiographyTemplate">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <TextBlock Text="{Binding Name}"
                    Foreground="Yellow"
                    FontSize="28"
                    HorizontalAlignment="Center"
                    Margin="0 48 0 0" />
        <TextBlock Text="{Binding  Description}"
                    Grid.Row="1"
                    FontSize="20"
                    TextWrapping="Wrap"
                    Margin="0 48 0 0" />
    </Grid>
</DataTemplate>

<!-- Powers And Abilities -->
<DataTemplate x:Key="PowersAndAbilitiesTemplate">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <TextBlock Text="{Binding Name}"
                    Foreground="Yellow"
                    FontSize="28"
                    HorizontalAlignment="Center"
                    Margin="0 48 0 0" />
        <ItemsControl ItemsSource="{Binding Powers}"
                        Grid.Row="1"
                        Margin="0 48 0 0"
                        HorizontalAlignment="Center">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <TextBlock FontSize="20">
                        <Run Text="● " />
                        <Run Text="{Binding}" />
                    </TextBlock>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
        <TextBlock Text="Weaknesses"
                    Grid.Row="2"
                    Foreground="Yellow"
                    FontSize="28"
                    HorizontalAlignment="Center"
                    Margin="0 48 0 0" />
        <ItemsControl ItemsSource="{Binding Weaknesses}"
                        Grid.Row="3"
                        Margin="0 48 0 0"
                        HorizontalAlignment="Center">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <TextBlock FontSize="20">
                        <Run Text="● " />
                        <Run Text="{Binding}" />
                    </TextBlock>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </Grid>
</DataTemplate>
When a data template is not found in the resources, the selector returns a Null value. The data binding engine then applies a default template, with the fully qualified type name in a text box. Here’s how this looks like:

During debugging, the Assert statement writes an exception to the output window when the template is not found, like this:

That’s all there is. Actually, the title of this article was longer than its source code. Here is the sample app: U2UConsult.Win8.DataTemplating.zip (692.39 kb)
Enjoy!
Diederik

Could not find a part of the path ... bin\roslyn\csc.exe

I am trying to run an ASP.NET MVC (model-view-controller) project retrieved from TFS (Team Foundation Server) source control. I have added a...