This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<add name="SQLAuthentication_ConnectionString" connectionString="Data Source=SQL_AUTH_DB_SERVER;Initial Catalog=SQL_AUTH_DB_NAME;Persist Security Info=True;User ID=SQL_AUTH_DB_USER_ID;pwd=SQL_AUTH_DB_USER_PASSWORD;MultipleActiveResultSets=true;" providerName="System.Data.SqlClient" /> | |
<add name="WindowsAuthentication_ConnectionString" connectionString="Data Source=WINDOWS_SQL_AUTH_DB_SERVER;Initial Catalog=WINDOWS_SQL_AUTH_DB_NAME;Persist Security Info=True;User ID=WINDOWS_SQL_AUTH_DB_USER_ID;pwd=WINDOWS_SQL_AUTH_DB_USER_PASSWORD;MultipleActiveResultSets=true;" providerName="System.Data.SqlClient" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleTable | |
{ | |
public int ID { get; set; } | |
public string Name { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ISampleService | |
{ | |
List<SampleTable> GetSampleList(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleService : ISampleService | |
{ | |
IContext _context; | |
public SampleService(IContext context) | |
{ | |
_context = context; | |
} | |
public List<SampleTable> GetSampleList() | |
{ | |
var availabelData = _context.SampleTables.ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IContext | |
{ | |
IDbSet<SampleTable> SampleTables { get; set; } | |
DbSet<TEntity> Set<TEntity>() where TEntity : class; | |
DbEntityEntry<TEntity> Entry<TEntity>(TEntity entity) where TEntity : class; | |
Database Database { get; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestDBContext : DbContext, IContext | |
{ | |
public TestDBContext() : base("Name=DB_CONNECTION_STRING"){} | |
public TestDBContext(DbConnection existingConnection, bool contextOwnsConnection) : base(existingConnection, contextOwnsConnection){} | |
protected override void OnModelCreating(DbModelBuilder modelBuilder) | |
{ | |
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); | |
base.OnModelCreating(modelBuilder); | |
} | |
public IDbSet<SampleTable> SampleTables { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ServiceModule : Module | |
{ | |
protected override void Load(ContainerBuilder builder) | |
{ | |
try | |
{ | |
builder.RegisterAssemblyTypes(System.Reflection.Assembly.Load("Service")).Where(t => t.Name.EndsWith("Service")).AsImplementedInterfaces().InstancePerLifetimeScope(); | |
} | |
catch (Exception ex) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EFModule : Module | |
{ | |
protected override void Load(ContainerBuilder builder) | |
{ | |
try | |
{ | |
builder.RegisterType(typeof(TestDBContext)).As(typeof(IContext)).InstancePerLifetimeScope(); | |
} | |
catch (Exception ex) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleInitialize | |
{ | |
private readonly ISampleService _oSampleService; | |
public SampleInitialize(ISampleService oSampleService) | |
{ | |
_oSampleService = oSampleService; | |
} | |
public void Run() | |
{ | |
var _list = _oSampleService.GetSampleList(); |
OlderNewer