Last active
June 10, 2016 03:09
-
-
Save jklemmack/95722a1c5ae28f9179cdd141c271564b to your computer and use it in GitHub Desktop.
Example of inconsistent boolean clause behavior in ServiceStack ORMLite 4.0.58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ServiceStack.DataAnnotations; | |
using ServiceStack.OrmLite; | |
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace SSOrmLiteTest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var dbFactory = new OrmLiteConnectionFactory("", SqlServer2012Dialect.Provider); | |
var db = dbFactory.CreateDbConnection(); | |
var exp1 = db.From<Account>() | |
.LeftJoin<CardHolder>((a, ch) => a.Id == ch.AccountId && ch.TestBoolB == true); | |
Debug.WriteLine(exp1.BodyExpression); | |
var exp2 = db.From<Account>() | |
.LeftJoin<CardHolder>((a, ch) => a.Id == ch.AccountId && a.TestBoolA == true); | |
Debug.WriteLine(exp2.BodyExpression); | |
var exp3 = db.From<Account>() | |
.Where(a => a.TestBoolA == true); | |
Debug.WriteLine(exp3.BodyExpression); | |
} | |
} | |
public class Account | |
{ | |
[PrimaryKey] | |
public int Id { get; set; } | |
public bool TestBoolA { get; set; } | |
} | |
public class CardHolder | |
{ | |
[PrimaryKey] | |
public int Id { get; set; } | |
[References(typeof(Account))] | |
public int AccountId { get; set; } | |
public bool TestBoolB { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment