MikeGriffinReborn / EntitySpaces

EntitySpaces - A Fluent SQL library for .NET
24 stars 20 forks source link

EntitySpaces Studio generates buggy classes for views #6

Open HeikoAdams opened 4 years ago

HeikoAdams commented 4 years ago

Version 2019.1.1218.0 of EntitySpaces Studio generates buggy code for view clases.

Every generated view class gets at least a constructor which requires a join alias but the GetDynamicQuery or Query methods of the same generated classes are calling a non existing constructor without parameters.

HeikoAdams commented 4 years ago

This is an example class generated by es studio ViewReturns.zip

MikeGriffinReborn commented 4 years ago

Oh shoot, I will fix that tonight, I haven't been testing views, easy fix, sorry about that, watch for a fix tonight hopefully

MikeGriffinReborn commented 4 years ago

Okay, I just generated some Views off my Northwind database, both Custom and Generated classes. They are compiling just fine, I can't tell by just looking at the class you gave me what the issue is. Can your provide me with more information?

HeikoAdams commented 4 years ago

What kind of information do need/prefer?

MikeGriffinReborn commented 4 years ago

Okay, I think I see the issue, for some reason their is a weird capitalization issue going on?

For instance ...

public partial class ViewReturns : EsViewReturns
{

}

Notice the "EsViewReturns" .... this should be "esViewReturns ... (lower case "es").

Looking into it. Your custom class is probably inheriting from "esViewReturns" lower case and thus the compiler errors ....

Did you change the prefix in the EntitySpaces Studio "Settings" => "Naming Conventions" tab by chance?

HeikoAdams commented 4 years ago

Did you change the prefix in the EntitySpaces Studio "Settings" => "Naming Conventions" tab by chance?

Yes, because M$ naming conventions require classnames starting with an upper case letter.

Hint: I'm using the fxcop nuget

MikeGriffinReborn commented 4 years ago

Hmmm, well then you must make sure your Custom Class is inheriting from the Es version, you might need to manually change your "Custom" class.

HeikoAdams commented 4 years ago

Hmmm, well then you must make sure your Custom Class is inheriting from the Es version, you might need to manually change your "Custom" class.

I'll check when I'm back at work tomorrow

HeikoAdams commented 4 years ago

Okay, I've checked it and the inheritance is correct.

MikeGriffinReborn commented 4 years ago

Can you post a cheesy project showing the compiler error or post the compiler error? I simply cannot reproduce this.

HeikoAdams commented 4 years ago

The view-query class itself doesn't compile with compiler error "there is no constructor which accepts 0 arguments"

HeikoAdams commented 4 years ago

The class constructor signature is public ViewReturnsQuery(string joinAlias) but at least public ViewReturnsQuery Query creates a new query instance by calling this.query = new ViewReturnsQuery();

HeikoAdams commented 4 years ago

Okay I figured out that changing line 80 of Generated - Query (C#).est from public <%=source.Query%>(string joinAlias) to public <%=source.Query%>(string joinAlias = "<%=source.Query%>")

HeikoAdams commented 4 years ago

A fix for this is also part of my pull request #13