コード例 #1
0
ファイル: Program.cs プロジェクト: mitev-web/acad-asp-mvc
        static void Main(string[] args)
        {
            //Try to open two different data contexts and perform concurrent changes on
            //the same records. What will happen at SaveChanges()? How to deal with it?

            NorthwindEntities db1 = new NorthwindEntities();
            NorthwindEntities db2 = new NorthwindEntities();

            Customer c1 = (from cs in db1.Customers
                         where cs.ContactName == "Maria Anders"
                         select cs).First();

            Customer c2 = (from cs in db2.Customers
                          where cs.ContactName == "Maria Anders"
                          select cs).First();

            c1.ContactName = "Maria Popova";

            c2.ContactName = "Maria Georgieva";

            c1.Sa
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //Create a database called NorthwindTwin with the same structure as Northwind
            //using the features from ObjectContext. Find for the API for schema generation
            //    in MSDN or in Google.

            NorthwindEntities context = new NorthwindEntities();
            string DBscript;

            DBscript = context.CreateDatabaseScript();
            //DBscript.Replace("Northwind", "NorthwindTwin");
            DBscript = "CREATE DATABASE [NorthwindTwin] \ngo  \nuse [NorthwindTwin] \n" + DBscript;

            //Create NEW file
            StreamWriter northwindTwinFile = new StreamWriter("CreateNorthwindTwinDB2.sql");

            //Save the script from NorthwindDB in the created file(saveTheFile)
            using (northwindTwinFile)
            {
                northwindTwinFile.WriteLine(DBscript);
            }
            Console.WriteLine(DBscript);
        }
コード例 #3
0
ファイル: DAO.cs プロジェクト: mitev-web/acad-asp-mvc
 static DAO()
 {
     db = new NorthwindEntities();
 }