Video Executing SQL Query in LINQ to SQL


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExecutingSQLQuery
{
    class Program
    {
        static void Main(string[] args)
        {
            DataClasses1DataContext context = new DataClasses1DataContext();
            int a = 1;
            var result = context.ExecuteQuery<Person>("select * from Person where PersonID= {0}",a);
            foreach (var r in result)
            {
                Console.WriteLine(r.FirstName + r.LastName);
            }
            Console.ReadKey(true);
            var result1 = context.ExecuteQuery<Person>("select * from Person");
            foreach (var r in result1)
            {
                Console.WriteLine(r.FirstName + r.LastName);
            }

            Console.ReadKey(true);
        }
    }
}

********************************

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Learning Video Executing Stored Procedure in LINQ to SQL

Source code used in Video


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StoredProcedure
{
    class Program
    {
        static void Main(string[] args)
        {
            DataClasses1DataContext context = new DataClasses1DataContext();
            // Call SP with parameter
            int studentID = 2;
            var result=  context.GetStudentGrades(studentID);
            foreach (var r in result)
            {
                Console.WriteLine(r.Grade);
            }

            // call SP with parameter
            int? a=1;
            var result1 = context.GetStudentCount(ref a);
            Console.WriteLine(a);

            Console.ReadKey(true);

        }
    }
}

***********************************************************

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine