示例#1
0
        static void Main()
        {
            sqlpracticeEntities entites = new sqlpracticeEntities();
            int empno;

            Console.WriteLine("Enter Employ No   ");
            empno = Convert.ToInt32(Console.ReadLine());
            EMp result = entites.EMps.Where(x => x.Empno == empno).FirstOrDefault <EMp>();

            Console.WriteLine(result.Empno);
            Console.WriteLine(result.nam);
            Console.WriteLine(result.dept);
        }
        static void Main(string[] args)
        {
            sqlpracticeEntities entities = new sqlpracticeEntities();
            // foreach(int x in emp)
            var result = entities.EMps.Select(x => x);

            Console.WriteLine("Employ Records are  ");
            foreach (var v in result)
            {
                Console.WriteLine("Employ No  " + v.Empno);
                Console.WriteLine("Employ Name  " + v.nam);
                Console.WriteLine("Department  " + v.dept);
                Console.WriteLine("Designation  " + v.desig);
                Console.WriteLine("Basic   " + v.basic);
                Console.WriteLine("--------------------------------------------");
            }
        }
        static void Main()
        {
            EMp emp = new EMp();

            Console.WriteLine("Enter Employ No    ");
            emp.Empno = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter Employ Name   ");
            emp.nam = Console.ReadLine();
            Console.WriteLine("Enter Department  ");
            emp.dept = Console.ReadLine();
            Console.WriteLine("Enter Designation  ");
            emp.desig = Console.ReadLine();
            Console.WriteLine("Enter Basic   ");
            emp.basic = Convert.ToInt32(Console.ReadLine());
            sqlpracticeEntities entities = new sqlpracticeEntities();

            entities.EMps.Add(emp);
            entities.SaveChanges();
            Console.WriteLine("*** Record Inserted ***");
        }