Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with unbound Parameters #192

Merged
merged 7 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Detail of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:20
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:12

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework v6.1](http://msdn.microsoft.com/en-us/data/aa937723) (EF).
Expand Down Expand Up @@ -143,5 +143,11 @@ More will appear as we move forward.*
* DateTime Where Compare With Static Variable (line 35)


### Group: Additional Features
#### [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs):
- Supported
* Subquery As Context Extension Method (line 68)



The End
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Detail With Sql of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:20
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:12

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework v6.1](http://msdn.microsoft.com/en-us/data/aa937723) (EF).
Expand Down Expand Up @@ -832,5 +832,35 @@ SELECT



### Group: Additional Features
#### [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs):
- Supported
* Subquery As Context Extension Method (line 68)
* T-Sql executed is

```SQL
SELECT
[Project4].[EfParentId] AS [EfParentId],
CASE WHEN ([Project4].[C1] IS NULL) THEN 0 ELSE [Project4].[C2] END AS [C1]
FROM ( SELECT
[Project2].[EfParentId] AS [EfParentId],
[Project2].[C1] AS [C1],
(SELECT TOP (1)
[Extent3].[EfChildId] AS [EfChildId]
FROM [dbo].[EfChilds] AS [Extent3]
WHERE [Extent3].[EfParentId] = [Project2].[EfParentId]) AS [C2]
FROM ( SELECT
[Extent1].[EfParentId] AS [EfParentId],
(SELECT TOP (1)
[Extent2].[EfChildId] AS [EfChildId]
FROM [dbo].[EfChilds] AS [Extent2]
WHERE [Extent2].[EfParentId] = [Extent1].[EfParentId]) AS [C1]
FROM [dbo].[EfParents] AS [Extent1]
) AS [Project2]
) AS [Project4]
```




The End
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Summary of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:20
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:12

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework v6.1](http://msdn.microsoft.com/en-us/data/aa937723) (EF).
Expand Down Expand Up @@ -54,5 +54,9 @@ More will appear as we move forward.*
* [Strings](../TestGroup50Types/Test01Strings.cs) (4 tests)
* [DateTime](../TestGroup50Types/Test05DateTime.cs) (1 tests)

### Group: Additional Features
- Supported
* [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs) (1 tests)


The End
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System.Linq;
using DelegateDecompiler.EntityFramework.Tests.EfItems;
using DelegateDecompiler.EntityFramework.Tests.Helpers;
using NUnit.Framework;

namespace DelegateDecompiler.EntityFramework.Tests.TestGroup90AdditionalFeatures
{
public static class EfTestDbContextExtensions
{
[Computed]
public static int GetFirstChildIdByParent(this EfTestDbContext context, int pId)
{
return context.EfChildren.Where(a => a.EfParentId == pId).Select(b => b.EfChildId).FirstOrDefault();
}
}

class Test01NestedExpressions
{
private ClassEnvironment classEnv;

[OneTimeSetUp]
public void SetUpFixture()
{
classEnv = new ClassEnvironment();
}

class ParentIdWithFirstChildId
{
public int ParentId { get; set; }
public int FirstChildId { get; set; }

public override bool Equals(object obj)
{
return obj is ParentIdWithFirstChildId id && id.ParentId == ParentId && id.FirstChildId == FirstChildId;
}

public override int GetHashCode()
{
return ParentId * 131 + FirstChildId;
}
}

[Test]
#if EF_CORE && !EF_CORE3 && !EF_CORE5
[Ignore("Not natively supported in EF_CORE < 3")]
#endif
public void TestSubqueryAsContextExtensionMethod()
{
using (var env = new MethodEnvironment(classEnv))
{
//SETUP
var linq = env.Db.EfParents.Select(x => new ParentIdWithFirstChildId()
{
ParentId = x.EfParentId,
FirstChildId = env.Db.EfChildren.Where(a => a.EfParentId == x.EfParentId).Select(b => b.EfChildId).FirstOrDefault()
}).ToList();

//ATTEMPT
env.AboutToUseDelegateDecompiler();
var query = env.Db.EfParents.Select(x => new ParentIdWithFirstChildId()
{
ParentId = x.EfParentId,
FirstChildId = env.Db.GetFirstChildIdByParent(x.EfParentId)
}).Decompile();
var dd = query.ToList();

//VERIFY
env.CompareAndLogList(linq, dd);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Detail of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:21
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:12

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) (EF).
Expand Down Expand Up @@ -144,5 +144,9 @@ More will appear as we move forward.*
* DateTime Where Compare With Static Variable (line 35)


### Group: Additional Features
#### [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs):



The End
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Detail With Sql of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:21
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:12

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) (EF).
Expand Down Expand Up @@ -510,5 +510,9 @@ More will appear as we move forward.*



### Group: Additional Features
#### [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs):



The End
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Summary of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:21
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:12

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) (EF).
Expand Down Expand Up @@ -54,5 +54,7 @@ More will appear as we move forward.*
* [Strings](../TestGroup50Types/Test01Strings.cs) (4 tests)
* [DateTime](../TestGroup50Types/Test05DateTime.cs) (1 tests)

### Group: Additional Features


The End
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Detail of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:21
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:11

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) (EF).
Expand Down Expand Up @@ -142,5 +142,11 @@ More will appear as we move forward.*
* DateTime Where Compare With Static Variable (line 35)


### Group: Additional Features
#### [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs):
- Supported
* Subquery As Context Extension Method (line 68)



The End
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Detail With Sql of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:21
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:11

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) (EF).
Expand Down Expand Up @@ -496,5 +496,17 @@ More will appear as we move forward.*



### Group: Additional Features
#### [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs):
- Supported
* Subquery As Context Extension Method (line 68)
* T-Sql executed is

```SQL

```




The End
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Summary of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:21
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:11

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) (EF).
Expand Down Expand Up @@ -54,5 +54,9 @@ More will appear as we move forward.*
* [Strings](../TestGroup50Types/Test01Strings.cs) (4 tests)
* [DateTime](../TestGroup50Types/Test05DateTime.cs) (1 tests)

### Group: Additional Features
- Supported
* [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs) (1 tests)


The End
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Detail of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:21
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:11

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) (EF).
Expand Down Expand Up @@ -142,5 +142,11 @@ More will appear as we move forward.*
* DateTime Where Compare With Static Variable (line 35)


### Group: Additional Features
#### [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs):
- Supported
* Subquery As Context Extension Method (line 68)



The End
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Detail With Sql of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:21
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:11

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) (EF).
Expand Down Expand Up @@ -764,5 +764,21 @@ WHERE [e].[StartDate] > '2000-01-01T00:00:00.0000000'



### Group: Additional Features
#### [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs):
- Supported
* Subquery As Context Extension Method (line 68)
* T-Sql executed is

```SQL
SELECT [e0].[EfParentId] AS [ParentId], COALESCE((
SELECT TOP(1) [e].[EfChildId]
FROM [EfChildren] AS [e]
WHERE [e].[EfParentId] = [e0].[EfParentId]), 0) AS [FirstChildId]
FROM [EfParents] AS [e0]
```




The End
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Summary of supported commands
============
## Documentation produced for DelegateDecompiler, version 0.30.0 on Tuesday, 14 December 2021 22:21
## Documentation produced for DelegateDecompiler, version 0.30.0 on Thursday, 13 October 2022 16:11

This file documents what linq commands **DelegateDecompiler** supports when
working with [Entity Framework Core](https://docs.microsoft.com/en-us/ef/core/) (EF).
Expand Down Expand Up @@ -54,5 +54,9 @@ More will appear as we move forward.*
* [Strings](../TestGroup50Types/Test01Strings.cs) (4 tests)
* [DateTime](../TestGroup50Types/Test05DateTime.cs) (1 tests)

### Group: Additional Features
- Supported
* [Nested Expressions](../TestGroup90AdditionalFeatures/Test01NestedExpressions.cs) (1 tests)


The End
Loading