Skip to content

Instantly share code, notes, and snippets.

View FransBouma's full-sized avatar

Frans Bouma FransBouma

View GitHub Profile
@FransBouma
FransBouma / OrderDetailDoc.cs
Last active August 26, 2015 14:09
Generated class from Derived Element (element derived from entity graph / entity sub model, denormalized). LLBLGen Pro v5. Attributes re added using rules (so defined once)
//------------------------------------------------------------------------------
// <auto-generated>This code was generated by LLBLGen Pro v5.0.</auto-generated>
//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@FransBouma
FransBouma / gist:8933631
Created February 11, 2014 12:02
How silly the Telerik DataAccess wizard is.
// in the generated massive file for fluent mappings.
public partial class FluentModel : OpenAccessContext, IFluentModelUnitOfWork
{
private static string connectionStringName = @"AdventureWorksConnection";
private static BackendConfiguration backend = GetBackendConfiguration();
// The line below is generated by the Telerik 'wizard' (which should actually be called 'dumbass') and causes the code to recreate the mapping model
// every time.
@FransBouma
FransBouma / gist:9736633
Created March 24, 2014 08:53
Even with 20+ years of development experience, Monday mornings are hard...
object newValueInType = newValue;
string newValueAsString = newValue as string;
if(type == typeof(DateTimeOffset))
{
newValueInType = DateTimeOffset.Parse(newValueAsString);
}
if(type == typeof(Guid))
{
newValueInType = Guid.Parse(newValueAsString);
}
@FransBouma
FransBouma / gist:10393394
Last active August 29, 2015 13:58
LLBLGen Pro typed list generated as poco + query (Linq or QuerySpec) (v4.2)
// Generated linq queries:
/// <summary>Gets the query to fetch the typed list OneToManyPocoLinq</summary>
public IQueryable<Northwind.Adapter.TypedListClasses.OneToManyPocoLinqRow> GetOneToManyPocoLinqTypedList()
{
var current0 = this.Customer;
var current1 = from c in current0
join o in this.Order on c.CustomerId equals o.CustomerId
join od in this.OrderDetails on o.OrderId equals od.OrderId
select new {o, c, od };
@FransBouma
FransBouma / gist:10972512
Last active August 29, 2015 13:59
Creating Expression<Func<T>> at runtime.
// these lambda's are used in e.g. projections in typed queries to materialize object arrays into typed objects.
// running this 100000 times at runtime takes 20551ms
System.Linq.Expressions.Expression<Func<OrderPocoQsRow>> l = () => new NW26.Adapter.TypedViewClasses.OrderPocoQsRow()
{
CustomerId = OrderPocoQsFields.CustomerId.ToValue<System.String>(),
EmployeeId = OrderPocoQsFields.EmployeeId.ToValue<Nullable<System.Int32>>(),
Freight = OrderPocoQsFields.Freight.ToValue<Nullable<System.Decimal>>(),
OrderDate = OrderPocoQsFields.OrderDate.ToValue<Nullable<System.DateTime>>(),
OrderId = OrderPocoQsFields.OrderId.ToValue<System.Int32>(),
RequiredDate = OrderPocoQsFields.RequiredDate.ToValue<Nullable<System.DateTime>>(),
@FransBouma
FransBouma / gist:11211671
Created April 23, 2014 11:30
First Typed View (read only poco, mapped onto view) tests succeeding in LLBLGen Pro Linq Provider:
[Test]
public void TypedViewPocoTest1()
{
using(var adapter = new DataAccessAdapter())
{
var metaData = new LinqMetaData(adapter);
var q = (from i in metaData.InvoicesPocoLinq
where i.Country == "USA"
select i)
Non-change tracking individual fetches (100 elements, 10 runs), no caching
------------------------------------------------------------------------------
Handcoded materializer using DbDataReader : 0,79ms per individual fetch
PetaPoco Fast v4.0.3 : 0,90ms per individual fetch
LLBLGen Pro v4.2.0.0 (v4.2.14.0424), Poco typed view with QuerySpec : 0,95ms per individual fetch
LLBLGen Pro v4.2.0.0 (v4.2.14.0424), typed view : 1,21ms per individual fetch
Linq to Sql v4.0.0.0 (v4.0.30319.33440) : 2,53ms per individual fetch
LLBLGen Pro v4.2.0.0 (v4.2.14.0424), Poco typed view with Linq : 6,50ms per individual fetch
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 14">
@FransBouma
FransBouma / gist:8403b388aa30d3207be2
Last active August 29, 2015 14:08
How in-memory .net calls are in-lined in the final query in LLBLGen Pro's linq provider
var q = ctx.Customers.Select(c=>new Customer() { CompName = SomeMethod(c.CompanyName)});
-> visit the select lambda, and convert it so it becomes:
(values, indices) => new Customer() { CompName = SomeMethod(values[indices[0]])};
then compile the lambda. At projection time, execute the lambda with the object[] obtained from the datareader as 'values'
and a set of indices, one for each db value placed in the project. This way you can have any in-memory call in the projection
@FransBouma
FransBouma / enbeffectprepass.fx
Created March 23, 2015 12:06
enbeffectprepass.fx with desaturation
//////////////////////////////////////////////////////////////////////////
// //
// ENBSeries effect file //
// visit http://enbdev.com for updates //
// Copyright (c) 2007- Boris Vorontsov //
// //
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
// //
// enbeffectprepass.fx depth of field by kingeric1992, //
// based on GDC 2004 presentation: //