Expert Dot Net

Trust me to find new way !

LINQ Aggregate on an array with tenary operator

using System;

using System.Collections;

using System.Collections.Generic;

using System.Text;

using System.Linq;

 

public class LINQDemo2{

   public static void Main(){

       int[] numbers = { 9, 3, 5, 4, 2, 6, 7, 1, 8 };

       var query = numbers.Aggregate(5, (a,b) => ( (a < b) ? (a * b) : a));

    }

}

 

LINQ Aggregate Use

using System;

using System.Collections;

using System.Collections.Generic;

using System.Text;

using System.Linq;

 

public class LINQDemo1 {

    public static void Main() {

        int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

        var query = numbers.Aggregate((a, b) => a * b);

    }

}

What is – DML, DDL, DCL and TCL

DML - is abbreviation of Data Manipulation Language. It is used to retrieve, store, modify, delete, insert and update data in database.

e.g.: SELECT, UPDATE, INSERT statements

DDL - is abbreviation of Data Definition Language. It is used to create and modify the structure of database objects in database.

e.g.: CREATE, ALTER, DROP statements

DCL -is abbreviation of Data Control Language. It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it.

e.g.: GRANT, REVOKE statements

TCL - is abbreviation of Transactional Control Language. It is used to manage different transactions occurring within a database.

Introduction to SQL

Introduction to SQL

  1. SQL stands for Structured Query Language
  2. SQL lets you access and manipulate databases
  3. SQL is an ANSI (American National Standards Institute) standard
Use of SQL

  1. SQL can execute queries against a database
  2. SQL can retrieve data from a database
  3. SQL can insert records in a database
  4. SQL can update records in a database
  5. SQL can delete records from a database
  6. SQL can create new databases
  7. SQL can create new tables in a database
  8. SQL can create stored procedures in a database
  9. SQL can create views in a database
  10. SQL can set permissions on tables, procedures, and views

How to Create Basic HTTP Binding in WCF

BasicHttpBinding

BasicHttpBinding is suitable for communicating with ASP.NET Web Service (ASMX) based services that conform to the WS-Basic Profile that conforms with Web Services.

  1. This binding uses HTTP as the transport and text/XML as the default message encoding.
  2. Security is disabled by default.
  3. This binding does not support WS-* functionalities like WS- Addressing, WS-Security, WS-ReliableMessaging.

Let's get started. Use the following procedure.

  1. Create a WCF basicHttpBinding project.
  2. Start Visual Studio and select New Project from the Start page or from the File menu, select New and then Project.
  3. After selecting, a dialog will pop up showing all the templates provided by Visual Studio.
  4. From the Installed Templates select C# then inside that select WCF and inside that you will select WCF Service Application. 

Introduction to WCF

Introduction to WCF

Windows Communication Foundation (Code named Indigo) is a programming platform and runtime system for building, configuring and deploying network-distributed services. It is the latest service oriented technology; Interoperability is the fundamental characteristics of WCF. It is unified programming model provided in .Net Framework 3.0. WCF is a combined features of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication.


Please refer the below Image




There are certain advantages and disadvantages as well which is given below :


Advantage

WCF is interoperable with other services when compared to .Net Remoting,where the client and service have to be .Net.

WCF services provide better reliability and security in compared to ASMX web services.

In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small changes in the configuration will make your requirements.

WCF has integrated logging mechanism, changing the configuration file settings will provide this functionality. In other technology developer has to write the code.

Disadvantage

Making right design for your requirement is little bit difficult. I will try to help you on solving these difficulties in the following article.

C# Basic Syntax

C#-Basic Syntax 

C# is an object-oriented programming language. In Object-Oriented Programming methodology, a program consists of various objects that interact with each other by means of actions. The actions that an object may take are called methods. Objects of the same kind are said to have the same type or, are said to be in the same class.

For example, let us consider a Rectangle object. It has attributes such as length and width. Depending upon the design, it may need ways for accepting the values of these attributes, calculating the area, and displaying details.

Let us look at demo of a Rectangle class and discuss C# basic syntax:

using System;
namespace RectangleDemo
{
   class Rectangle 
   {
      // member variables
      double length;
      double width;
      public void Acceptdetails()
      {
         length = 4.5;    
         width = 3.5;
      }
      
      public double GetArea()
      {
         return length * width; 
      }
      
      public void Display()
      {
         Console.WriteLine("Length: {0}", length);
         Console.WriteLine("Width: {0}", width);
         Console.WriteLine("Area: {0}", GetArea());
      }
   }
   
   class ExecuteRectangle 
   {
      static void Main(string[] args) 
      {
         Rectangle r = new Rectangle();
         r.Acceptdetails();
         r.Display();
         Console.ReadLine(); 
      }
   }
}

When the above code is compiled and executed, it produces the following result:

Length: 4.5
Width: 3.5
Area: 15.75

The using Keyword

The first statement in any C# program is

using System;

The using keyword is used for including the namespaces in the program. A program can include multiple using statements.

The class Keyword

The class keyword is used for declaring a class.

Comments in C#

Comments are used for explaining code. Compilers ignore the comment entries. The multiline comments in C# programs start with /* and terminates with the characters */ as shown below:

/* This program demonstrates
The basic syntax of C# programming 
Language */

Single-line comments are indicated by the '//' symbol. For example,

}//end class Rectangle    

Member Variables

Variables are attributes or data members of a class, used for storing data. In the preceding program, the Rectangle class has two member variables named length and width.

Member Functions

Functions are set of statements that perform a specific task. The member functions of a class are declared within the class. Our sample class Rectangle contains three member functions: AcceptDetails, GetArea and Display.

Instantiating a Class

In the preceding program, the class ExecuteRectangle contains the Main()method and instantiates the Rectangle class.

Identifiers

An identifier is a name used to identify a class, variable, function, or any other user-defined item. The basic rules for naming classes in C# are as follows:

·        A name must begin with a letter that could be followed by a sequence of letters, digits (0 - 9) or underscore. The first character in an identifier cannot be a digit.

·        It must not contain any embedded space or symbol such as? - + ! @ # % ^ & * ( ) [ ] { } . ; : " ' / and \. However, an underscore ( _ ) can be used.

·        It should not be a C# keyword.

C# .net Tutorial

C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its .NET initiative led by Anders Hejlsberg. This tutorial will teach you basic C# programming and will also take you through various advanced concepts related to C# programming language.

Audience

This tutorial has been prepared for the beginners to help them understand basic C# programming.

Prerequisites

C# programming is very much based on C and C++ programming languages, so if you have a basic understanding of C or C++ programming, then it will be fun to learn C#.

Execute C# 

Try following example -

using System;

namespace HelloWorldApplication

{

   class HelloWorld

   {

      static void Main(string[] args)

      {

         /* my first program in C# */

         Console.WriteLine("Hello World");

         Console.ReadKey();

      }

   }

}