Skip to content

Instantly share code, notes, and snippets.

@evan-boissonnot
Created February 21, 2019 15:04
Show Gist options
  • Save evan-boissonnot/494ec443221f62a0e2f672ececd5be17 to your computer and use it in GitHub Desktop.
Save evan-boissonnot/494ec443221f62a0e2f672ececd5be17 to your computer and use it in GitHub Desktop.
generic db set, generic add
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace TestAspNetMvcNet.Models
{
public class BaseDataLayer<T>
{
public void Add(T item)
{
using (KartinaEntities context = new KartinaEntities())
{
var dbSet = context.Set(typeof(T));
dbSet.Add(item);
context.SaveChanges();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment