Details

    • Sprint:

      Description

      string.Substring(index, length) behaves different in linq2nh and linq2obj. It is because in sql substring's parameter index is one-based and in C# is zero-based.

      So following query would produce unexpeced sql

      from e in db.Employees
      where e.FirstName.Substring(1) == "An"
      select e;

      select
      employee0_.*
      from
      Employees employee0_
      where
      substring(employee0_.FirstName, @p0, @p1)=@p2;
      @p0 = 1 Type: Int32 (0), @p1 = 2 Type: Int32 (0), @p2 = 'An'

      NOTE: should be substring(employee0_.FirstName, @p0+1, @p1)

      And Substring(index) for following query also generates incorrect sql

      select
      employee0_.*
      from
      Employees employee0_
      where
      substring(employee0_.FirstName, 0, @p0)=@p1;
      @p2 = 1 Type: Int32 (0), @p1 = 'An'

      NOTE: should be substring(employee0_.FirstName, @p0+1, len(employee0_.FirstName)-@p0)

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                hazzik Alexander Zaytsev
              • Votes:
                1 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Who's Looking?