static void Main() { const string connectionString = @"Server=(local)\SQLEXPRESS;DataBase=MiniORM;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); //var emploees = context.Employees.ToList(); var newEmployee = new Employee { FirstName = "CC", LastName = "CCCCC", DepartmentId = context.Departments.First().Id, IsEmployed = true }; context.Employees.Add(newEmployee); context.SaveChanges(); var secondEmployee = new Employee { FirstName = "DD", LastName = "DDDDD", DepartmentId = context.Departments.First().Id, IsEmployed = true }; context.Employees.Add(secondEmployee); context.SaveChanges(); //Case 2 //var employee = context.Employees.Single(e => e.Id == 8); //employee.MiddleName = "Jr."; //context.SaveChanges(); }
public static void Main() { const string connectionString = @"Server=(local)\SQLEXPRESS;DataBase=MiniORM;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); //var emploees = context.Employees.ToList(); var newEmployee = new Employee { FirstName = "Pesho", LastName = "Petrov", DepartmentId = context.Departments.First().Id, IsEmployed = true }; context.Employees.Add(newEmployee); context.SaveChanges(); var secondEmployee = new Employee { FirstName = "Gosho", LastName = "Georgiev", DepartmentId = context.Departments.First().Id, IsEmployed = true }; context.Employees.Add(secondEmployee); context.SaveChanges(); }
static void Main() { var connectionString = File.ReadAllText(@"F:\base\MSSQL_connectionString.txt"); var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "King", LastName = "Zerkan", IsEmployed = true }); context.Projects.Add(new Project { Name = "JavaScript Project" }); //context.EmployeesProjects.Add(new EmployeeProject //{ // ProjectId = context.Projects.Last().Id, // EmployeeId = context.Employees.Last().Id //}); var employee = context.Employees.Last(); employee.DepartmentId = context.Departments.First().Id; context.SaveChanges(); }
public static void Main(string[] args) { var connectionString = @"Server=DESKTOP-8Q6AF3G\SQLEXPRESS;Database=MiniORM;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = context.Departments.First().Id, IsEmployed = true, }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.Departments.Add(new Department { Name = "Sales" }); context.Departments.Remove(context.Departments.Where(x => x.Name == "Sales").First()); context.SaveChanges(); }
public static void Main(string[] args) { var connectionString = @"Server=DESKTOP-B3I8JPR\SQLEXPRESS;Database=MiniORM;Integrated Security = true"; var context = new SoftUniDbContext(connectionString); //context.Employees.Add(new Employee //{ // FirstName = "Gosho", // LastName = "Inserted", // DepartmentId = context.Departments.First().Id, // IsEmployed = true, //}); //var employee = context.Employees.Last(); //employee.FirstName = "Modified"; context.Departments.Add(new Department { Name = "Department1" }); context.SaveChanges(); context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Employee1FirstName", LastName = "Employee1LastName", DepartmentId = 1, IsEmployed = true }); context.Employees.Add(new Employee { FirstName = "Employee2FirstName", LastName = "Employee2LastName", DepartmentId = 1, IsEmployed = true }); context.Employees.Add(new Employee { FirstName = "Employee3FirstName", LastName = "Employee3LastName", DepartmentId = 1, IsEmployed = true }); context.SaveChanges(); context = new SoftUniDbContext(connectionString); Console.WriteLine(string.Join(" ", context.Departments.Single(d => d.Id == 1).Employees.Select(e => e.FirstName))); Console.WriteLine(); Console.WriteLine(string.Join(" ", context.Employees.Where(e => e.DepartmentId == 1).Select(e => e.FirstName))); //context.SaveChanges(); }
public static void Main() { SoftUniDbContext db = new SoftUniDbContext(Configuration.ConnectionString); db.Employees.Add(new Employee("Rado", "Radov", db.Departments.First().Id, true)); Employee employee = db.Employees.Last(); employee.FirstName = "Rado"; db.SaveChanges(); }
public static void Main() { const string connectionString = "Server=DESKTOP-8DBTK91\\SQLEXPRESS02;Database=MiniORM;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Traiko", LastName = "Peshov", DepartmentId = context.Departments.First().Id, IsEmployeed = true }); context.SaveChanges(); }
static void Main(string[] args) { var connectionString = @"Server=YEHIAZZ-PC\SQLEXPRESS;Database = MiniORM;Integrated Security = true"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = context.Departments.First().Id, IsEmployed = true }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
static void Main() { SoftUniDbContext context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Vladimir", LastName = "Dodnikov", DepartmentId = context.Departments.First().Id, IsEmployed = true }); Employee employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
public static void Main() { var context = new SoftUniDbContext(Constants.ConnectionString); context.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = context.Departments.First().Id, IsEmployed = true }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
static void Main(string[] args) { var connectionString = @"Server = whatever; Integrated Security = true; Initial Catalog = MiniORM"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = context.Departments.First().Id, IsEmployed = true }); var employee = context.Employees.Last(); employee.FirstName = "KRASIMIR"; context.SaveChanges(); }
static void Main(string[] args) { var db = new SoftUniDbContext(connectionString); db.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = db.Departments.First().Id, IsEmployed = true }); var employee = db.Employees.Last(); employee.FirstName = "Modified"; db.SaveChanges(); }
public static void Main(string[] args) { const string connectionString = @"Server=(LocalDb)\MSSQLLocalDB;Database=MiniOrmDB;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = context.Departments.First().Id, IsEmployed = true }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
public static void Main() { var connectionString = @"Server=.\SQLEXPRESS;Database=MiniORM;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Ivan", LastName = "Ivanov", DepartmentId = context.Departments.First().Id, IsEmployed = true }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
public static void Main() { var connectionString = @"Server=DESKTOP-58UASJ8\SQLEXPRESS;Database=MiniORM;Integrated Security=True"; SoftUniDbContext db = new SoftUniDbContext(connectionString); db.Employees.Add(new Employee ( "Gosho", "Inserted", db.Departments.First().Id, true )); Employee employee = db.Employees.Last(); employee.FirstName = "Modified"; db.SaveChanges(); }
public static void Main(string[] args) { var connectionString = @"Server=DESKTOP-AE56UDL\SQLEXPRESS;Database=MiniORM;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Mega", LastName = "Manqk", DepartmentId = context.Departments.First().Id, IsEmployed = false, }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
static void Main(string[] args) { var connectionString = @"Server=.;Database=MiniORM;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Mo", LastName = "Salah", DepartmentId = context.Departments.First().Id, IsEmployed = true }); //var employee = context.Employees.Last(); //employee.FirstName = "Zvone"; //employee.LastName = "Boban"; context.SaveChanges(); }
public static void Main() { var connectionString = @"Server=(localdb)\MyInstance;Database=MiniORM;Integrated security=True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Gancho", LastName = "Ganchov", DepartmentId = context.Departments.First().Id, IsEmployed = true }); var employee = context.Employees.Last(); employee.FirstName = "Hello"; context.SaveChanges(); }
public static void Main() { var connectionString = @"Server=localhost\sqlexpress;Database=MiniORM;Trusted_Connection=True;"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = context.Departments.First().Id, IsEmployed = true }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
static void Main(string[] args) { var connectionString = @"Server=DESKTOP-FDQOU2P;Database=MiniORM;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee() { FirstName = "asdqwd12", LastName = "d12d1d2", DepartmentId = context.Departments.First().Id, IsEmployed = true }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
public static void Main(string[] args) { var connectionString = "Server=.;Database=MiniORM;Integrated Security=true"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Kaladin", LastName = "Stormblessed", DepartmentId = context.Departments.First().Id, IsEmployed = true, }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
public static void Main() { string connectionString = @""; // <-- Insert Connection String Here; SoftUniDbContext context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = context.Departments.First().Id, IsEmployed = true }); Employee employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
static void Main(string[] args) { var connectionString = "Server=.;Database = MiniORM; Integrated Security=true;"; //Change the Server to whatever your Server name is var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = context.Departments.First().Id, IsEmployed = true, }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
static void Main(string[] args) { string connectionString = "Server=.;Database=MiniORM;Integrated Security =true"; SoftUniDbContext context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Tervel", LastName = "Dimov", DepartmentId = context.Departments.First().Id, IsEmployed = true }); Employee employee = context.Employees.Last(); employee.FirstName = "Aleksander"; context.SaveChanges(); }
static void Main(string[] args) { const string connectionString = @"Data Source=(local)\SQLEXPRESS; Initial Catalog = MiniORM; Integrated Security = true"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Emilia", LastName = "Nedialkova", DepartmentId = context.Departments.First().Id, IsEmployed = true, }); var employee = context.Employees.Last(); context.SaveChanges(); //Test System.Console.WriteLine($"First Name:{employee.FirstName}, Last Name:{employee.LastName}"); }
static void Main(string[] args) { const string connectionString = "Server=(localdb)\\MSSQLLocalDB; Database =MiniORM; Integrated Security = True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Lyubmir", MiddleName = "Georgiev", LastName = "Georgiev", DepartmentId = 1, IsEmpolyed = true }); var employee = context.Employees.Last(); employee.FirstName = "NoEnoughtTimeForCoding"; context.SaveChanges(); }
public static void Main(string[] args) { var connectionString = "Server=.;Database=MiniORM;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Updated", MiddleName = "Abdalov", LastName = "Losho", DepartmentId = context.Departments.First().Id, IsEmployed = true, }); var employee = context.Employees.Last(); employee.FirstName = "Morb"; context.SaveChanges(); }
static void Main() { var connectionString = "Server=.;Database=MiniORM;Integrated Security=true"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Petya", LastName = "Tancheva", DepartmentId = context.Departments.First().Id, IsEmployed = true, }); Employee employee = context.Employees.Last(); System.Console.WriteLine(employee.FirstName + " " + employee.LastName); context.Employees.Remove(employee); context.SaveChanges(); }
static void Main(string[] args) { string connectionString = "Server=DESKTOP-F0IMF0D\\SQLEXPRESS;" + "Database=MiniORM;" + "Integrated Security=true"; SoftUniDbContext context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = context.Departments.First().Id, IsEmployed = true }); Employee employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }
public static void Main(string[] args) { //TODO -> Add config to Server on ConnectionString var connectionString = @"Server=.;Database=MiniORM;Integrated Security=True"; var context = new SoftUniDbContext(connectionString); context.Employees.Add(new Employee { FirstName = "Gosho", LastName = "Inserted", DepartmentId = context.Departments.First().Id, IsEmployed = true, }); var employee = context.Employees.Last(); employee.FirstName = "Modified"; context.SaveChanges(); }