This file contains hidden or 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
// Copy and Paste this code into LINQPad and use the Nutshell database | |
void Main() | |
{ | |
var text = @"$Purchase.Customer.Name purchased $Detail on $Purchase.Date for $$$Purchase.Price"; | |
var Hello = new ExpressionTemplate<PurchaseItem>(text); | |
var query = PurchaseItems.Select(Hello.ToExpr()); | |
query.ToString().Dump("SQL"); |
This file contains hidden or 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
/// <summary> | |
/// This snippet extends Matthias Hertel's Difference algorithm and extends it to a | |
/// LINQ provider proof-of-concept. To run, simply copy+paste into LINQPad. | |
/// | |
/// http://www.mathertel.de/Diff/ | |
/// | |
/// Copyright (c) by Matthias Hertel, http://www.mathertel.de | |
/// This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx | |
/// | |
/// </summary> |
This file contains hidden or 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
void Main() | |
{ | |
var r = new Random().Values(0, 10).Let(list => list); | |
var l1 = r.Take(10); | |
var l2 = r.Take(10); | |
l1.SequenceEqual(l2).Dump("Should be equal"); | |
var l3 = r.Take(20); | |
l3.Take(10).SequenceEqual(l1).Dump("Should start with same sequence"); | |
var l4 = r.Take(20); |
This file contains hidden or 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 MustInherit Class LazyXMLBase | |
Implements IEnumerable(Of XNode) | |
Public MustOverride Function Render() As XNode | |
Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of System.Xml.Linq.XNode) Implements System.Collections.Generic.IEnumerable(Of System.Xml.Linq.XNode).GetEnumerator | |
Return Enumerable.Repeat(Me.Render(), 1).GetEnumerator() | |
End Function | |
Public Function GetEnumerator1() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator |
This file contains hidden or 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
Option Strict On | |
Imports Allied | |
Imports BaseTest.TestExtensions | |
Imports Microsoft.VisualStudio.TestTools.UnitTesting | |
Imports System.Xml.Linq | |
Imports System.Collections.Generic | |
<TestClass()> _ | |
Public Class MParserTest |
This file contains hidden or 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
// This will generate a database, but EF will not materialize the objects | |
// because our types do not have default parameterless constructors | |
namespace DataModel | |
open System | |
open System.ComponentModel.DataAnnotations | |
open System.Data.Entity | |
type User = { mutable ID : int; mutable Name: string; mutable DB: DateTime; mutable Tasks: Task[]; | |
mutable Projects: Project[] } |
This file contains hidden or 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
namespace NextWeb.Collections | |
open System | |
open System.Runtime.CompilerServices | |
type ITree<'a> = | |
abstract member Value: 'a | |
abstract member Children: seq<ITree<'a>> | |
[<Extension>] |
This file contains hidden or 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
open System | |
open System.Linq | |
open System.Collections.Generic | |
open System.Linq.Expressions | |
type SortOrder = Asc | Desc | |
type MongoQuery<'a> private(queryable:IQueryable<'a>, filters, sortFn, takeQty, skipQty) as this = | |
new(query) = MongoQuery(query, [], None, None, None) | |
member this.Where(filter:Expression<Func<'a,bool>>) = |
This file contains hidden or 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
void Main() { | |
string line; | |
int runningTotal = 0, input = 0; | |
do { | |
line = Console.ReadLine(); | |
if (Int32.TryParse(line, out input)) { | |
runningTotal += input; | |
Console.WriteLine(runningTotal); | |
} else if (line == "quit" || line == null) { |
This file contains hidden or 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
void Main() { | |
var doWork = CreatePipeLineFunc(async (int x) => { | |
var delay = ((x % 3) + 1) * 1000; | |
await Task.Delay(delay); | |
return new { x, delay }; | |
}, maxDegreeOfParallelism: 10); | |
Enumerable.Range(1, 100).Select(m => doWork(m)).Dump(); | |
} |
OlderNewer