所以在找 Linq To Entity Framework的方法
結果 哈哈哈 差不多東西阿 換湯不換藥
使用起來還是很簡單的說 XD
只是一開始是做Linq To Sql 變成做Entity Data Model
呼叫方式變成
LinqDataContext linqDB = new LinqDataContext();
Entities1 entity1 = new Entities1();
接下來就都一樣囉 >_^
程式筆記本 把所使用過的程式與電腦問題記錄下來 我想把這裡串成一本活字典
LinqDataContext linqDB = new LinqDataContext();
Entities1 entity1 = new Entities1();
//this.textBox1 = new System.Windows.Forms.TextBox(); //這個改成下面那個
this.textBox1 = new wmgCMS.WaterMarkTextBox(); //改成這個
//---------元件設定部份
this.textBox1 .WaterMarkColor = System.Drawing.Color.Gray;
this.textBox1 .WaterMarkText = "浮水印要顯示的字";
//---------最下面
//private System.Windows.Forms.TextBox textBox1; //這個改成下面那個
private wmgCMS.WaterMarkTextBox textBox1; //改成這個
FolderBrowserDialog path = new FolderBrowserDialog();
path.ShowDialog();
textBox1.Text = path.SelectedPath;
OpenFileDialog file = new OpenFileDialog();
file.ShowDialog();
textBox1.Text = file.SafeFileName;
ConnectionOptions options = new ConnectionOptions();
options.Username = "Username"; // 使用者名稱
options.Password = "Password"; // 使用者密碼
options.Authentication = AuthenticationLevel.Default; // 認證模式設定 (採用預設)
options.Impersonation = ImpersonationLevel.Impersonate; // 設定 COM 模擬等級
options.EnablePrivileges = true; // 參考 **(特一)
try
{
ManagementScope MS_Conn = new ManagementScope("\\\\" + "IP" + "\\root\\cimv2", options);
MS_Conn.Connect();
ObjectQuery oq = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher mos1 = new ManagementObjectSearcher(MS_Conn, oq);
ManagementObjectCollection moc1 = mos1.Get();
foreach (ManagementObject mo in moc1)
{
mo.InvokeMethod("Reboot", null);
}
}
catch (Exception err1)
{
textBox1.Text= err1.Message;
}
string sourcePath = @"C:\Users\Public\TestFolder";
string targetPath = @"C:\Users\Public\TestFolder\SubDir";
System.IO.File.Copy(sourceFile, destFile, true);
System.IO.File.Move(sourceFile, destinationFile);
if(System.IO.File.Exists(@"C:\Users\Public\DeleteTest\test.txt"))
{
// Use a try block to catch IOExceptions, to
// handle the case of the file already being
// opened by another process.
try
{
System.IO.File.Delete(@"C:\Users\Public\DeleteTest\test.txt");
}
catch (System.IO.IOException e)
{
Console.WriteLine(e.Message);
return;
}
}
if (!System.IO.Directory.Exists(targetPath))
{
System.IO.Directory.CreateDirectory(targetPath);
}
if (System.IO.Directory.Exists(sourcePath))
{
string[] files = System.IO.Directory.GetFiles(sourcePath);
// Copy the files and overwrite destination files if they already exist.
foreach (string s in files)
{
// Use static Path methods to extract only the file name from the path.
fileName = System.IO.Path.GetFileName(s);
destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(s, destFile, true);
}
}
else
{
Console.WriteLine("Source path does not exist!");
}
System.IO.Directory.Move(@"C:\Users\Public\public\test\", @"C:\Users\Public\private");
if(System.IO.Directory.Exists(@"C:\Users\Public\DeleteTest"))
{
try
{
System.IO.Directory.Delete(@"C:\Users\Public\DeleteTest", true);
}
catch (System.IO.IOException e)
{
Console.WriteLine(e.Message);
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
int ascii = Convert.ToInt16(e.KeyChar);
if ((ascii >= 97 && ascii <= 122) || (ascii == 8))
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
private void textBox1_Validating(object sender, CancelEventArgs e)
{
try
{
int numberEntered = int.Parse(textBox1.Text);
if (numberEntered < 1 || numberEntered > 10)
{
e.Cancel = true;
MessageBox.Show("You have to enter a number between 1 and 10");
}
}
catch (FormatException)
{
e.Cancel = true;
MessageBox.Show("You need to enter an integer");
}
}
DataTable1.Columns.Add("ImageValue", typeof(Image));
Image OnlineImage = Image.FromFile("online.png");
DataTable1.Rows[i]["ImageValue"] = OnlineImage;
dataGridView1.DataSource = DataTable1;