Giter Club home page Giter Club logo

expressionextensionsql's People

Contributors

ahaeber avatar codacy-badger avatar felipespinelli avatar gambarra avatar tiagor87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

expressionextensionsql's Issues

True OrElse getting rendered as just '1'

Not sure if you are familiar with the PredicateBuilder but it is quite popular and allows easy building on the fly. I've been using this particular version of it because it does not rely Linq-to-Sql InvocationExpressions (which definitely won't work with this extension you've built). So for example it allows us to build it with multiple ANDs and ORs in the WHERE clause like this:

var inner = PredicateBuilder.False<Product>();
inner = inner.Or(p => p.ProductGroupID == 10);
inner = inner.Or(p => p.ProductGroupID == 11);

var outer = PredicateBuilder.True<Product>();
outer = outer.And(p => p.StatusID == 2);
outer = outer.And(inner);

That first line is causing the issue, it's supposed to be just an entry point for the expression tree to build off of but when the SQL gets generated you wind up with (note: bolded sections):

SELECT * FROM [Product] WHERE ((1 AND ([Product].[StatusID] = ( 2))) AND ((0 OR ([Product].[ProductGroupID] = ( 10))) OR ([Product].[ProductGroupID] = ( 11))))

Looking at the expression being built by the PredicateBuilder you see

(True OrElse (param.ProductGroupID == Convert(10, Nullable1)))`

So that True OrElse is causing the problem, it probably should get rendered as 1=1 instead of just 1? What do you think?

Wrong EntityName in Generated SQL when an Expression is using a member defined in ancestor of the entity.

Let's say one used a BaseEntity like this
public class BaseEntity
{
public string Id {get; set;}
}
and want to generate a SQL Expression for this Entity:
public class Derived: BaseEntity
{
public string AnotherField {get; set;}
}

Let's say we have to expressions:

a) Expression<Func<Derived, bool>> = (p)=>p.AnotherField = "A"
b) Expression<Func<Derived, bool>> = (p)=>p.Id = "A"

the former (A) gives, when traslated to SQL, something like "AnotherField = @p1" which is fine.
the latter (B) gives, when traslated to SQL, something like "[BaseEntity].Id = @p1" which is incorrect. it should be
"[Derived].Id = @p1"

Basically, when the SQL Expression is generated, the entity name should be the most derived class for a member name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.