public Form1() { InitializeComponent(); var db = new ContactManagerDBEntities(); contactBindingSource.DataSource = db.Contacts.ToList(); }
private void Form1_Load(object sender, EventArgs e) { db = new ContactManagerDBEntities(); contactBindingSource.DataSource = db.Contacts.ToList(); contactTypeBindingSource.DataSource = db.ContactTypes.ToList(); var logical = Directory.GetLogicalDrives(); }
private void AddContact_Load(object sender, EventArgs e) { comboBoxContactId.DisplayMember = "Contact Type"; comboBoxContactId.ValueMember = "ContactTypeID"; using (ContactManagerDBEntities db = new ContactManagerDBEntities()) { comboBoxContactId.DataSource = db.ContactTypes.ToList(); } }
private void buttonJson_Click(object sender, EventArgs e) { //ContactManagerDBEntities db; //Contact asd = new Contact(); //string json = JsonConvert.SerializeObject(asd, Formatting.Indented); //textBox2.Text = json; //File.WriteAllText(@"C:\Contact.json", JsonConvert.SerializeObject(asd)); //using (StreamWriter file = File.CreateText(@"C:\Contact.json")) //{ // JsonSerializer serializer = new JsonSerializer(); // serializer.Serialize(file,asd); //} //JsonSerializer js = new JsonSerializer(); //ContactManagerDBEntities db = new ContactManagerDBEntities(); //var myvalues = (from x in db.Contacts where (x.ContactID == 1) select x).ToList(); ////return js.Serialize(myvalues); //string output = JsonConvert.SerializeObject(_data); //System.IO.File.WriteAllText(@"c:\Contacts.json", output); var db = new ContactManagerDBEntities(); var result = (from c in db.Contacts join x in db.ContactTypes on c.ContactTypeID equals x.ContactTypeID select new ContactInfo { Ime = c.Ime, LastName = c.LastName, Address = c.Address, InsertDate = c.InsertDate, Captions = x.Caption }).ToArray(); dataGridView1.DataSource = result; var json = JsonConvert.SerializeObject(result, Formatting.Indented); File.WriteAllText(@"C:\Users\thcja\Documents\Demojson.json", JsonConvert.SerializeObject(result)); using (var file = File.CreateText(@"C:\Users\thcja\Documents\Demojson.json")) { var serializer = new JsonSerializer(); serializer.Serialize(file, result); } }