Skip to content

Instantly share code, notes, and snippets.

@jklemmack
Last active June 10, 2016 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jklemmack/95722a1c5ae28f9179cdd141c271564b to your computer and use it in GitHub Desktop.
Save jklemmack/95722a1c5ae28f9179cdd141c271564b to your computer and use it in GitHub Desktop.
Example of inconsistent boolean clause behavior in ServiceStack ORMLite 4.0.58
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