Skip to content

Instantly share code, notes, and snippets.

View nozzlegear's full-sized avatar
🌸
There is no theory, only the knowing.

Joshua Harms nozzlegear

🌸
There is no theory, only the knowing.
View GitHub Profile
@nozzlegear
nozzlegear / gist:11184132
Created April 22, 2014 15:42
Never update certain entity properties using Entity Framework
//Open database context
using(DbContext db = new DbContext())
{
//Get the id of the entity we want to update
int id = 1;
//Create an instance of the entity we want to update
SomeEntity entity = new SomeEntity(){
Id = id,
@nozzlegear
nozzlegear / gist:11183928
Created April 22, 2014 15:36
Updating all properties on an entity using Entity Framework
//Open database context
using(DbContext db = new DbContext())
{
//Get the id of the entity we want to update
int id = 1;
//Create an instance of the entity we want to update
SomeEntity entity = new SomeEntity(){
Id = id,
@nozzlegear
nozzlegear / gist:11183775
Created April 22, 2014 15:32
Updating specific properties on an entity using Entity Framework
//Open database context
using(DbContext db = new DbContext())
{
//Get the id of the entity we want to update
int id = 1;
//Create an instance of the entity we want to update
SomeEntity entity = new SomeEntity(){
Id = id,