• Stars
    star
    526
  • Rank 83,797 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 12 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library which is able to decompile a delegate or a method body to its lambda representation

DelegateDecompiler celebrates 10th year anniversary 🎂

https://ci.appveyor.com/project/hazzik/delegatedecompiler/branch/main https://nuget.org/packages/DelegateDecompiler

A library that is able to decompile a delegate or a method body to their lambda representation

Sponsorship

If you like the library please consider supporting my work.

Examples

Using computed properties in linq.

Asume we have a class with a computed property

class Employee
{
    [Computed]
    public string FullName => FirstName + " " + LastName;

    public string LastName { get; set; }

    public string FirstName { get; set; }
}

And you are going to query employees by their full names

var employees = (from employee in db.Employees
                 where employee.FullName == "Test User"
                 select employee).Decompile().ToList();

When you call .Decompile method it decompiles your computed properties to their underlying representation and the query will become simmilar to the following query

var employees = (from employee in db.Employees
                 where (employee.FirstName + " " + employee.LastName)  == "Test User"
                 select employee).ToList();

If your class doesn't have a [Computed] attribute, you can use the .Computed() extension method..

var employees = (from employee in db.Employees
                 where employee.FullName.Computed() == "Test User"
                 select employee).ToList();

Also, you can call methods that return a single item (Any, Count, First, Single, etc) as well as other methods in identical way like this:

bool exists = db.Employees.Decompile().Any(employee => employee.FullName == "Test User");

Again, the FullName property will be decompiled:

bool exists = db.Employees.Any(employee => (employee.FirstName + " " + employee.LastName) == "Test User");

Using with EntityFramework and other ORMs

If you are using ORM specific features, like EF's Include, AsNoTracking or NH's Fetch then Decompile method should be called after all ORM specific methods, otherwise it may not work. Ideally use Decompile extension method just before materialization methods such as ToList, ToArray, First, FirstOrDefault, Count, Any, and etc.

Async Support with EntityFramework 6

The DelegateDecompiler.EntityFramework package provides DecompileAsync extension method which adds support for EF's Async operations.

Async Support with EntityFramework Core 2.0-3.1

The DelegateDecompiler.EntityFrameworkCore package provides DecompileAsync extension method which adds support for EF's Async operations.

Async Support with EntityFramework Core 5.0 and later

The DelegateDecompiler.EntityFrameworkCore5 package provides DecompileAsync extension method which adds support for EF's Async operations.

Installation

Available on NuGet

License

MIT license - http://opensource.org/licenses/mit

More Repositories

1

HtmlAgilityPack

[DEPRECATED] unofficial HtmlAgilityPack fork
C#
23
star
2

TreeListView

http://www.codeproject.com/Articles/30721/WPF-TreeListView-Control
C#
17
star
3

OoMapper

Object-Obect Mapper, written in .NET
C#
14
star
4

Brandy

Web application framework for fast start and rapid development
C#
11
star
5

HtmlParser

[LAB] Simple lightweight html parser written in .net
C#
9
star
6

Grapes

Work with persistent tree structures easily
C#
9
star
7

Tail.Fody

C#
8
star
8

ReSharper.XUnitTestRunner

[DEPRECATED] xUnit .net (http://xunit.codeplex.com) runner for ReSharper 6 and above
C#
8
star
9

ReSharper.DictionaryHelper

C#
8
star
10

beerconf-website

JavaScript
8
star
11

ReSharper.StringFormat

A pluging for ReSharper which provides context action to replace strings interpolated with embedded variables to string.Format method call with these variables as arguments.
C#
7
star
12

PublicSuffix

PublicSuffix - Highly optimized, very fast Domain Name parser using Mozilla's Public Suffix List (https://publicsuffix.org/)
C#
7
star
13

Maybe

Maybe monad for .net
C#
6
star
14

ReSharper.Reflection

A set of helpers for a reflection API
C#
6
star
15

MpqTool

C#
6
star
16

Rhino.Net

Rhino.Net is an open-source implementation of JavaScript written entirely in CSharp (port of Mozilla's Rhino https://www.mozilla.org/rhino/ )
C#
6
star
17

fluent-english

C#
6
star
18

mpqnav

C#
5
star
19

ReSharper.ReJS

Refactorings for JavaScript
C#
5
star
20

uwow2

World Of Warcraft homeserver written in c#
C#
4
star
21

d3proto

D3 server emulator
C#
4
star
22

mh-search-assist

JavaScript
4
star
23

ProjectTemplate

JavaScript
3
star
24

DropDowns

C#
3
star
25

GridMvc

An fork of https://gridmvc.codeplex.com/
C#
3
star
26

Web.Require

Web.require is client dependency framework
C#
3
star
27

PartCover.MSBuild

C#
2
star
28

EFBootstrapper

C#
2
star
29

EFConventions

Adds ability to use conventions with Entity Framework Code First
C#
2
star
30

Invoke-Expression

An extension method which is able to invoke a lambda expression
C#
2
star
31

ClubhouseDotNet

A REST client to the Clubhouse API
C#
2
star
32

ReSharper.NHibernate

Fork of https://code.google.com/p/nhplugin/
C#
1
star
33

nh-contrib-everything

C#
1
star
34

ResourcesConverter

Java to C# Resources Converter
C#
1
star
35

hazzik.ru

CSS
1
star
36

num_to_words.dart

A library to convert number to words
Dart
1
star
37

BenchmarkStringJoin

C#
1
star
38

ReSharper.VB

A set of SSR for VB.NET
1
star
39

NHibernate.Burrow

C#
1
star
40

rodovid-tools

Stuff for rodovid.org wiki project
JavaScript
1
star
41

locations.ged

1
star
42

SpanDeconstructors

SpanDeconstructors is a source package which allows you to use C# 7 deconstruction syntax to deconstruct spans into variables
Pascal
1
star
43

Samples-From-My-Blog

http://hazzik-samples.apphb.com
JavaScript
1
star
44

SpanBridge

A compatibility level to provide missing Span<> APIs
C#
1
star
45

telerikaspnetmvc

Reconstructed sources of http://telerikaspnetmvc.codeplex.com/
C#
1
star
46

Elmah.YouTrack

YouTrack error logger for Elmah
C#
1
star
47

t4mvc

t4mvc with support controllers outside of "Controllers" folder and views in separate project
1
star
48

Sharpen.Runtime

C#
1
star
49

WikiAccess

C#
1
star
50

NHibernate.DuckDB

C#
1
star