Esempio n. 1
0
        internal SortOrderHandle MakeSortOrderForTable(Type tableType)
        {
            var    tableHandle  = Metadata[tableType].Table;
            IntPtr sortOrderPtr = NativeSortOrder.create_for_table(tableHandle);

            return(CreateSortOrderHandle(sortOrderPtr));
        }
        private void AddSort(LambdaExpression lambda, bool isStarting, bool ascending)
        {
            var body = lambda.Body as MemberExpression;

            if (body == null)
            {
                throw new NotSupportedException($"The expression {lambda} cannot be used in an Order clause");
            }

            if (isStarting)
            {
                if (_optionalSortOrderHandle == null)
                {
                    _optionalSortOrderHandle = _realm.MakeSortOrderForTable(_retType);
                }
                else
                {
                    var badCall = ascending ? "By" : "ByDescending";
                    throw new NotSupportedException($"You can only use one OrderBy or OrderByDescending clause, subsequent sort conditions should be Then{badCall}");
                }
            }

            var sortColName = body.Member.Name;

            NativeSortOrder.add_sort_clause(_optionalSortOrderHandle, sortColName, (IntPtr)sortColName.Length, ascending ? (IntPtr)1 : IntPtr.Zero);
        }
Esempio n. 3
0
 protected override void Unbind()
 {
     NativeSortOrder.destroy(handle);
 }