hojjjat
سه شنبه 26 شهریور 1392, 14:47 عصر
معادل دستورات ado.net زیر در linq چیه؟؟؟
private void LoadFile(string fullName)
{
using (SqlConnection cn
= new SqlConnection("Data Source=MyComputerDataSource;Initial Catalog=Test;Integrated Security=True"))
{
cn.Open();
using (SqlCommand cmd
= new SqlCommand("select PDFFile from SavePDFTable where ID='" + "1" + "' ", cn))
{
using (SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.Defa ult))
{
if (dr.Read())
{
byte[] fileData = (byte[])dr.GetValue(0);
using (System.IO.FileStream fs = new System.IO.FileStream(fullName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite))
{
using (System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs))
{
bw.Write(fileData);
bw.Close();
}
}
}
dr.Close();
}
}
}
}
من تمامشو میفهمم فقط byte[] fileData = (byte[])dr.GetValue(0);
رو به زبان linq توضیح بدین
private void LoadFile(string fullName)
{
using (SqlConnection cn
= new SqlConnection("Data Source=MyComputerDataSource;Initial Catalog=Test;Integrated Security=True"))
{
cn.Open();
using (SqlCommand cmd
= new SqlCommand("select PDFFile from SavePDFTable where ID='" + "1" + "' ", cn))
{
using (SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.Defa ult))
{
if (dr.Read())
{
byte[] fileData = (byte[])dr.GetValue(0);
using (System.IO.FileStream fs = new System.IO.FileStream(fullName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite))
{
using (System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs))
{
bw.Write(fileData);
bw.Close();
}
}
}
dr.Close();
}
}
}
}
من تمامشو میفهمم فقط byte[] fileData = (byte[])dr.GetValue(0);
رو به زبان linq توضیح بدین