Friday, 22 November 2013

Difference Between LINQ and SQL Select with Group by Query  Syntax.

The select statement is used in SQL to specify what data you would like returned when querying the MSSQL MYSQL LINQ database. An asterisks [*] will return all data, or you can choose specific data.

The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns in SP View and Table data.


SQL : select(clause) * from (clause) from <table Name> where(clause) column =value 
        group by(clause) column name  order by   column name desc

           select * from customer where id =100  group by id order by created_date desc

LINQ : from <instance> in <table name or table object name> where (clause) column=value
            groupby(clause) ColumnName   orderby(clause) columnName asc   select <instance>

           from cust in customer where cust.id. Equuleus (100) groupBy cust.id
           orderby cust.created_date desc   select cust; 

 

Difference Between LINQ and SQL Select with Order by Query  Syntax.


The select statement is used in SQL to specify what data you would like returned when querying the MSSQL MYSQL LINQ database. An asterisks [*] will return all data, or you can choose specific data.

The ORDER BY keyword is used to sort the result-set by one or more columns in View Table and SP.
The ORDER BY keyword sorts the records in ascending order by default. To sort the records in a descending order, you can use the DESC keyword.


SQL : select(clause) * from (clause) from <table Name> where(clause) column =value order by
          column name desc

           select * from customer where id =100  order by created_date desc

LINQ : from <instance> in <table name or table object name> where (clause) column=value
          orderby(clause) columnName asc   select <instance>

           from cust in customer where cust.id. Equuleus (100) orderby cust.created_date desc
           select cust; 


 

Difference Between LINQ and SQL Select with Where Condition Query  Syntax.

The select statement is used in SQL to specify what data you would like returned when querying the MSSQL MYSQL LINQ database. An asterisks [*] will return all data, or you can choose specific data. 

The WHERE clause is used to extract only those records that fulfill a specified criterion.
The WHERE clause is used to filter the data in a table.
The WHERE clause is used to filter the data in a View.


SQL : select(clause) * from (clause) from <table Name> where(clause) column =value
           select * from customer where id =100

LINQ : from <instance> in <table name or table object name> where (clause) column=value
             select <instance>
           from cust in customer where cust.id. Equuleus (100) select cust; 


 

Difference Between LINQ and SQL Select Query  Syntax.


Select Only :
The select statement is used in SQL to specify what data you would like returned when querying the MSSQL MYSQL LINQ database. An asterisks [*] will return all data, or you can choose specific data.
SQL : select(clause) * from (clause) from <table Name>
            select * from employe.

LINQ : from <instance> in <table name or table object name> select <instance>
           from cust in customer select cust;

What is LINQ and Example 


Language-Integrated Query (LINQ) is a set of features introduced in Visual Studio 2008 that extends powerful query capabilities to the language syntax of C# and Visual Basic. LINQ introduces standard, easily-learned patterns for querying and updating data, and the technology can be extended to support potentially any kind of data store. Visual Studio includes LINQ provider assemblies that enable the use of LINQ with .NET Framework collections.

 SQL Server databases, ADO.NET Datasets, and XML documents.

Language-Integrated Query (LINQ) is the name for a set of technologies based on the integration of query capabilities directly into the C# language (also in Visual Basic and potentially any other .NET language).

With LINQ, a query is now a first-class language construct, just like classes, methods, events and so on.

Example :

class LINQQueryExample
{
    static void Main()
    {

        // Specify the data source. 
        int[] scores = new int[] { 97, 92, 81, 60,10,45,100,200 };

        // Define the query expression.
        IEnumerable<int> scoreQuery =
            from score in scores
            where score > 80
            select score; 
 
         SQL Syntax : select * from socres where column >80
  
       // Execute the query. 
        foreach (int i in scoreQuery)
        {
            Console.Write(i + " ");
        }            
    }
}
 
Result 81,92,97,100,200





Friday, 8 November 2013

Update Statement in (SQL and LINQ) and Syntax

The update statement is used to update or change records that match a specified criteria. This is accomplished by carefully constructing a where clause.

Syntax SQL :

UPDATE tablename
SET columnname = '000newvalue'
WHERE columnname= Teatvalue"  AND | OR  columnname=testvalue
 
Syntax LINQ : - 
 

What is Insert Statement In (SQL and LINQ) and Synthax

Insert command is called as DML functions.
this is very useful for inserting new records in data base.

Syntax  SQL :
Insert into tablename values(col1values ,cal2values...);

Syntax LINQ :

LinqToSQL objLinqToSQL = new LinqToSQL();

Employee   objEmployee =new Employee ();

objEmployee .EMPid=001;
objEmployee .First_name=Prasad;
objEmployee .Middle_Name=K;
objEmployee .Lost_Name=M;

objLinqToSQ.InsertALL( objEmployee);
objLinqToSQ.SubmitAll();
Example SQL :

Insert into Employee (001,'Prasad','K',M') Press F5 in MSSQL

 
Please check the result :

SQL :-
select * from  Employee  Press F5 in MSSQL

LINQ : 

var data=from d in  Employee select instance;

Result : -
----------------------------------------------------------------------------
 | Employe_id | First_Name | Middle_Name | Lost_Name|
---------------------------------------------------------------
 | 001              | Prasad          | K                      |M                 |
---------------------------------------------------------------

What is Table in SQL and Syntax

 A relational database system contains one or more objects called tables. The data or information for the database are stored in these tables.

Syntax :

Create table tablename
(
rowname and data types 
     col1 is row name
     varchar2(10) is data types.
);
 example : 

Create table Employee
(
   Employe_id  varchar2(10) not null,
  First_Name  varchar2(10) not null,
  Middle_Name  varchar2(10) not null,
  Lost_Name  varchar2(10) not null
) ;

Please write the select statement.

select * form Employee

Result :-

 | Employe_id | First_Name | Middle_Name | Lost_Name|

the result will look above .

What is SQL?

SQL is one most wonted language for data base activities.
 
SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems. SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database.

Some common relational database management systems that

 Use SQL for :
     Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc. Although most database systems use SQL, most of them also have their own additional proprietary extensions that are usually only used on their system.

Impotent  SQL Commands.
1. DDL
       Create", and "Drop"

2. DML

         "Select", "Insert", "Update", "Delete"

The above SQL commands are very use full for all type of data base programmers.  This tutorial will provide you with the instruction on the basics of each of these commands as well as allow you to put them to practice using the SQL Interpreter.