When using binary operator there are errors, in some conditions, for example:

Xtensive.Orm.SyntaxErrorException was unhandled
  HResult=-2146233088
  Message=SQL error occured.
SQL error details 'Type: SyntaxError;'
Query 'SELECT [a].[Id], 100 AS [TypeId], [a].[Enum] FROM [dbo].[MyEntity] [a] WHERE (([a].[Enum] & 4294967296) = 0);'
Original message 'The data types bigint and numeric are incompatible in the '&' operator.'

[HierarchyRoot]
public class MyEntity : Entity
{
    [Field]
    [Key]
    public Guid Id { get; set; }

    [Field]
    public MyEnum Enum { get; set; }
}

[Flags]
public enum MyEnum : long
{
    None = 0,
    Foo = 1,
    Bar = (long)1 << 32
}

class Program
{
    static void Main(string[] args)
    {

        var conf = new DomainConfiguration("sqlserver://localhost/DO40-Tests");
        conf.UpgradeMode = DomainUpgradeMode.Recreate;
        conf.Types.Register(typeof(MyEntity));

        using (var d1 = Domain.Build(conf))
        {
            var s = d1.OpenSession();

            s.Query.All<MyEntity>().Where(a => (a.Enum & MyEnum.None) == 0).ToArray();
            s.Query.All<MyEntity>().Where(a => (a.Enum & MyEnum.Foo) == 0).ToArray();
            s.Query.All<MyEntity>().Where(a => (a.Enum & MyEnum.Bar) == 0).ToArray();
        }
    }
}

asked Apr 09 '14 at 08:29

pil0t's gravatar image

pil0t
207575763

Hello pil0t, I can confirm your problem. We're currently investigating solution for it.

(Apr 15 '14 at 02:40) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

One Answer:

Fix would be available in the next 4.6 release

answered May 21 '14 at 00:45

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA