Skip to content

Instantly share code, notes, and snippets.

View mrstebo's full-sized avatar
💻

Steven Atkinson mrstebo

💻
View GitHub Profile
@mrstebo
mrstebo / UserService.cs
Created June 2, 2020 12:20
entity-framework-model-mapping-4
using System.Collections.Generic;
using EntityFrameworkExamples.Data;
using EntityFrameworkExamples.Models;
namespace EntityFrameworkExamples.Services
{
public class UserService
{
private readonly ApplicationContext _context;
@mrstebo
mrstebo / UserMapping.cs
Created June 2, 2020 12:20
entity-framework-model-mapping-3
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using EntityFrameworkExamples.Models;
namespace EntityFrameworkExamples.Mappings
{
class UserMapping : EntityTypeConfiguration<User>
{
public UserMapping()
{
@mrstebo
mrstebo / ApplicationContext.cs
Created June 2, 2020 12:18
entity-framework-model-mapping-2
using System.Data.Entity;
using EntityFrameworkExamples.Models;
namespace EntityFrameworkExamples.Data
{
public class ApplicationContext : DbContext
{
public virtual IDbSet<User> Users { get; set; }
public ApplicationContext()
@mrstebo
mrstebo / User.cs
Created June 2, 2020 12:17
entity-framework-model-mapping-1
namespace EntityFrameworkExamples.Models
{
public class User
{
public long Id { get; set; }
public string Username { get; set; }
public string Password { get; set; }
}
@mrstebo
mrstebo / UserService.cs
Created June 2, 2020 12:05
hello-entity-framework-2
public class UserService
{
private readonly ApplicationContext _context;
public UserService(ApplicationContext context)
{
_context = context;
}
public IEnumerable<User> GetUsers()
@mrstebo
mrstebo / UserService.cs
Created June 2, 2020 12:04
hello-entity-framework-1
public class UserService
{
public IEnumerable<User> GetUsers()
{
var ds = new DataSet();
using (var con = new SqlConnection("Server=myServerAddress;Database=myDataBase;UserId=myUsername;Password=myPassword;"))
{
using (var da = new SqlDataAdapter("SELECT * FROM Users", con))
{
@mrstebo
mrstebo / Keypad.cs
Created June 2, 2020 11:44
fez-panda-ii-with-matrix-keypad-3
using GHIElectronics.NETMF.FEZ;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using System;
namespace Keypad_Test
{
public class Program
{
static Cpu.Pin[] ColumnPins = new[]
@mrstebo
mrstebo / Keypad.cs
Created June 2, 2020 11:43
fez-panda-ii-with-matrix-keypad-2
public char[] GetKeys()
{
var s = "";
for (var i = 0; i < ColumnPins.Length; i++)
{
using (var output = new OutputPort(ColumnPins[i], false))
{
for (var j = 0; j < RowPins.Length; j++)
{
@mrstebo
mrstebo / Keypad.cs
Created June 2, 2020 11:42
fez-panda-ii-with-matrix-keypad-1
using Microsoft.SPOT.Hardware;
namespace Keypad_Test
{
class Keypad
{
public char[][] Keymap
{
get;
private set;
@mrstebo
mrstebo / TestConfig.cs
Created June 2, 2020 11:36
deriving-from-our-registryconfig-class-3
public sealed class TestConfig : RegistryConfig
{
public string TestSetting1
{
get
{
return GetValue(ParsePropertyMethodName(MethodBase.GetCurrentMethod().Name), string.Empty);
}
set
{