آره همین کارو میکنم، یه پروژه جدید مخصوص بروزرسانی "پروژه اصلی" تو سولوش ام ایجاد کردم.
1) این Entity Frameowrk به دیتابیس خاصی وابسته هستش؟ یا با هر دیتابیسی میشه ازش استفاده کرد؟
2) فرق Entity Frameowrk با linq-to-sql.dbml چیه؟ ( تو نت خوندم که linq-to-sql.dbml خودش جزئی از ado.net هستش؛ کم کم دارم گیج میشم با این اصلاحات

)
3) الان تو کد زیر من از چه روشی برا کدنویسی دسترسی به دیتابیس استفاده کردم؟


یه کلاس مدل تعریف کردم ( که دقیقا همون ستون های دیتابیس هستش ) و داده ای بخوام از دیتابیس بخونم یا بنویسم از این کلاس استفاده میکنم.
public static class TbNotifications{
#region Model
public class Model
{
public int ID { get; set; }
public string Title { get; set; }
public string Summary { get; set; }
public string Image { get; set; }
public string Time { get; set; }
public string Date { get; set; }
public string Content { get; set; }
public bool WillBeShown { get; set; }
}
#endregion
#region Functions
public static List<Model> ReadAllNotifications()
{
List<Model> data = new List<Model>();
try
{
using (SqlConnection conn = new SqlConnection(Database.Connetion))
{
conn.Open();
if (conn.State == System.Data.ConnectionState.Open)
{
using (SqlCommand cmd = conn.CreateCommand())
{
string query =
" SELECT *" +
" FROM TbNotifications";
cmd.CommandText = query;
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
data.Add(new Model
{
ID = (int)reader["ID"],
Title = reader["Title"].ToString(),
Summary = reader["Summary"].ToString(),
Image = reader["Image"].ToString(),
Time = reader["Time"].ToString(),
Date = reader["Date"].ToString(),
Content = reader["Content"].ToString(),
WillBeShown = (bool)reader["WillBeShown"],
});
}
}
}
}
}
}
catch (Exception ex)
{
Debug.WriteLine("Exception: " + ex.Message);
}
return data;
}
#endregion
}