Home
Add Document
Sign In
Create An Account
IRepository.cs Interface file. Repository.cs class file
− IRepository.cs Interface file using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Threading.Tasks; ...
Author:
Jesse Wood
3 downloads
0 Views
38KB Size
Report
Download PDF
Recommend Documents
File Systems: Interface. File Management Issues
File Concept. Chapter 11: File-System Interface. File Attributes. File Structure. File Operations. File Types Name, Extension
A Java Class File Parser
LONMARK Device Interface File Reference Guide
File class in Java. Scanner reminder. File methods. File Input and Output (Savitch, Chapter 10) TOPICS. Some methods in the File class:
Polymer Class Terms in the Registry File
New English File Int File 2
OS-9 File System. Disk File Organization
Additional file 30 - Additional file references. References
Malaria Fact-file. Malaria Fact - File
CxCReporting, Local File and Master File Documentation
services File
Subject File
File Investigator Application Programming Interface Manual. Version 3.12
Network File System. Network File System (NFS) NFS Advantages. Network File System Disadvantages
To open a CMA file > Download and Save file Start CMA Open file from within CMA
File Type: TEXT (XYZ Point File) Directions: XYZMF
The Grid File An Adaptable, Symmetric Multikey File Structure
Basic File Structures The Hash (Direct) File (1)
Detailed file layout for the LFS Micro data file
PRESS FILE Matmut ATLANTIQUE PRESS FILE SEPT 2015
File-System Structure. A Typical File Control Block (FCB) Layered File System in OS. Virtual File Systems. Schematic View of Virtual File System
To open a CMA file > Download and Save file Start CMA Open file from within CMA
Extensions of the UNIX File Command and Magic File for File Type Identification
− IRepository.cs Interface file using using using using using
System; System.Collections.Generic; System.Linq; System.Text; System.Threading.Tasks;
namespace MyClassLibrary { public interface IRepository where T : class { IQueryable GetAll(); T GetById(int id); void Add(T entity); void Update(T entity, int id); void Delete(T entity); void Delete(int id); } }
− Repository.cs class file using using using using using using using
System; System.Collections.Generic; System.Data; System.Data.Entity; System.Linq; System.Text; System.Threading.Tasks;
namespace MyClassLibrary { public class Repository : IRepository where T : class { protected DatabaseContext DbContext { get; set; } protected DbSet DbSet { get; set; }
public Repository(DatabaseContext dbContext) { if (dbContext == null) throw new NullReferenceException("dbContext"); DbContext = dbContext; DbSet = dbContext.Set(); }
public IQueryable GetAll() {
return DbSet; } public T GetById(int id) { return DbSet.Find(id); } public void Add(T entity) { DbSet.Add(entity); } public void Update(T entity, int id) { var entry = DbContext.Entry(entity); var currententry = GetById(id); DbContext.Entry(currententry).CurrentValues.SetValues(entity); } public void Delete(T entity) { var entry = DbContext.Entry(entity); DbSet.Attach(entity); entry.State = EntityState.Deleted; } public void Delete(int id) { var entity = GetById(id); if (entity == null) return; Delete(entity); } } }
− Database.cs class file using using using using using
System; System.Collections.Generic; System.Linq; System.Text; System.Threading.Tasks;
namespace MyClassLibrary { public class Database { private DatabaseContext _DatabaseContext; public Database(DatabaseContext _Databasecontext1)
{ _DatabaseContext = _Databasecontext1; } public IRepository Companies { get { return new Repository(_DatabaseContext); } } public void save() { _DatabaseContext.SaveChanges(); } } }
− ConnectionString
−
MainWindow.xaml
− Mainwindow.xaml.cs public partial class MainWindow : Window { private MyClassLibrary.Database db; private MyClassLibrary.DatabaseContext _dbcontext = new MyClassLibrary.DatabaseContext(); public MainWindow() { InitializeComponent(); } private void btndelete_Click(object sender, RoutedEventArgs e) { db = new MyClassLibrary.Database(_dbcontext); var newcompany = new Company(); newcompany.Id = newcompany.Id = Convert.ToInt32(txtid.Text.Trim()); db.Companies.Delete(newcompany.Id); db.save(); btnClear_Click(sender, e); companyDataGrid.Items.Refresh(); } private void btnupdate_Click(object sender, RoutedEventArgs e) { db = new MyClassLibrary.Database(_dbcontext); var newcompany = new Company(); newcompany.Id = Convert.ToInt32(txtid.Text.Trim()); newcompany.Name = txtname.Text.Trim(); newcompany.Telephone = txttelephone.Text.Trim(); newcompany.Email = txtemail.Text.Trim();
newcompany.GPS = txtgps.Text.Trim(); db.Companies.Update(newcompany, newcompany.Id); db.save(); btnClear_Click(sender, e); companyDataGrid.Items.Refresh(); } private void btnInsert_Click(object sender, RoutedEventArgs e) { db = new MyClassLibrary.Database(_dbcontext); var newcompany = new Company(); newcompany.Name = txtname.Text.Trim(); newcompany.Telephone = txttelephone.Text.Trim(); newcompany.Email = txtemail.Text.Trim(); newcompany.GPS = txtgps.Text.Trim(); db.Companies.Add(newcompany); db.save(); btnClear_Click(sender, e); companyDataGrid.Items.Refresh(); } private void btnClear_Click(object sender, RoutedEventArgs e) { txtid.Text = ""; txtname.Text = ""; txttelephone.Text = ""; txtemail.Text = ""; txtgps.Text = ""; } private void Window_Loaded_1(object sender, RoutedEventArgs e) { System.Windows.Data.CollectionViewSource companyViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("companyViewSource"))); // Load data by setting the CollectionViewSource.Source property: // companyViewSource.Source = [generic data source] _dbcontext.Companies.Load(); companyViewSource.Source = _dbcontext.Companies.Local; }
Suggest Documents
File Systems: Interface. File Management Issues
Read more
File Concept. Chapter 11: File-System Interface. File Attributes. File Structure. File Operations. File Types Name, Extension
Read more
A Java Class File Parser
Read more
LONMARK Device Interface File Reference Guide
Read more
File class in Java. Scanner reminder. File methods. File Input and Output (Savitch, Chapter 10) TOPICS. Some methods in the File class:
Read more
Polymer Class Terms in the Registry File
Read more
New English File Int File 2
Read more
OS-9 File System. Disk File Organization
Read more
Additional file 30 - Additional file references. References
Read more
Malaria Fact-file. Malaria Fact - File
Read more
CxCReporting, Local File and Master File Documentation
Read more
services File
Read more
Subject File
Read more
File Investigator Application Programming Interface Manual. Version 3.12
Read more
Network File System. Network File System (NFS) NFS Advantages. Network File System Disadvantages
Read more
To open a CMA file > Download and Save file Start CMA Open file from within CMA
Read more
File Type: TEXT (XYZ Point File) Directions: XYZMF
Read more
The Grid File An Adaptable, Symmetric Multikey File Structure
Read more
Basic File Structures The Hash (Direct) File (1)
Read more
Detailed file layout for the LFS Micro data file
Read more
PRESS FILE Matmut ATLANTIQUE PRESS FILE SEPT 2015
Read more
File-System Structure. A Typical File Control Block (FCB) Layered File System in OS. Virtual File Systems. Schematic View of Virtual File System
Read more
To open a CMA file > Download and Save file Start CMA Open file from within CMA
Read more
Extensions of the UNIX File Command and Magic File for File Type Identification
Read more
×
Report "IRepository.cs Interface file. Repository.cs class file"
Your name
Email
Reason
-Select Reason-
Pornographic
Defamatory
Illegal/Unlawful
Spam
Other Terms Of Service Violation
File a copyright complaint
Description
×
Sign In
Email
Password
Remember me
Forgot password?
Sign In
Login with Google
Login with Facebook