Skip to content

Instantly share code, notes, and snippets.

public static class WcfGen
{
private static string contractName;
private static string operationName;
private static Type clientProxyType;
private static CodeDomProvider codeDomProvider;
private static CompilerResults results;
private static Uri mexAddress;
@phatty
phatty / TransactionRecieved.cs
Created August 26, 2013 10:17
Transaction MSMQ
using System;
using System.Messaging;
namespace MyProject
{
/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
var objCtx = ((System.Data.Entity.Infrastructure.IObjectContextAdapter)Context).ObjectContext;
objCtx.ExecuteStoreCommand("TRUNCATE TABLE [ServiceArgs]");
@phatty
phatty / LeftJoin.cs
Created July 11, 2013 03:47
Left join once in for all
var Context = new CSPRedemptionEntities();
var List = from cp in Context.CouponPools
join cb in Context.CouponBatches
on new { CouponBatch_id = cp.CouponBatch_id } equals
new { CouponBatch_id = cb.id }
join m in Context.Members
on new { RedeempBy_id = cp.RedeemBy.Value } equals
new { RedeempBy_id = m.id} into MemberLeft
from x in MemberLeft.DefaultIfEmpty()
where cp.CouponBatch_id == CouponBatch_id && cp.Campaign_id == Campaign_id
var Records = context.Customers.Join(context.TransactionExchangeMoneys
, x => x.Cust_ID
, y => y.PayBy
, (x, y) => new { x, y })
.Join(context.Products
, t=> t.y.ProductID
, p => p.ProductID
, (t,p) => new {t,p})
.GroupBy(r => new { r.t.x.Cust_ID,r.t.x.UserNames ,r.t.x.EmailAddress_First,r.t.x.ShopName})
.Select(g => new UserAndMoneyPaid
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSP_PGP_Fileprocessor_util
{
static class TypeSwitch
{
public class CaseInfo {
using System;
using System.Data;
using System.Linq;
using System.Collections;
using System.Collections.Specialized;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.Collections.Generic;
using CSP_db_production_EntityDataAccess.Access;
using CSP_db_production_Utility.DataGridUtility;
@phatty
phatty / LinqDateTimeConversion
Created March 9, 2013 04:35
Convert nullable DateTime? to new format
public DataTable GetDelivery()
{
try
{
db_ProductionSystemEntities Context = this.GetContext();
//var Records = Context.T_DELIVERY
// .Include("T_CUST_INFO")
// .Include("T_SHIPPING_COMPANY");
@phatty
phatty / Type Switch
Created February 1, 2013 07:33
c# Type Switch More
new Switch(foo)
.Case<Fizz>
(action => { doingSomething = FirstMethodCall(); })
.Case<Buzz>
(action => { return false; })
public class Switch
{
public Switch(Object o)
{
@phatty
phatty / Type Switch1
Last active December 12, 2015 01:18
c# implement switch with Type
TypeSwitch.Do(
sender,
TypeSwitch.Case<Button>(() => textBox1.Text = "Hit a Button"),
TypeSwitch.Case<CheckBox>(x => textBox1.Text = "Checkbox is " + x.Checked),
TypeSwitch.Default(() => textBox1.Text = "Not sure what is hovered over"));
static class TypeSwitch {
public class CaseInfo {
public bool IsDefault { get; set; }
public Type Target { get; set; }