private static void AddQueryNotEqual(QueryHandle queryHandle, string columnName, object value) { var columnIndex = NativeQuery.get_column_index((QueryHandle)queryHandle, columnName, (IntPtr)columnName.Length); var valueType = value.GetType(); if (value.GetType() == typeof(string)) { string valueStr = (string)value; NativeQuery.string_not_equal((QueryHandle)queryHandle, columnIndex, valueStr, (IntPtr)valueStr.Length); } else if (valueType == typeof(bool)) { NativeQuery.bool_not_equal((QueryHandle)queryHandle, columnIndex, MarshalHelpers.BoolToIntPtr((bool)value)); } else if (valueType == typeof(int)) { NativeQuery.int_not_equal((QueryHandle)queryHandle, columnIndex, (IntPtr)((int)value)); } else if (valueType == typeof(long)) { NativeQuery.long_not_equal((QueryHandle)queryHandle, columnIndex, (long)value); } else if (valueType == typeof(float)) { NativeQuery.float_not_equal((QueryHandle)queryHandle, columnIndex, (float)value); } else if (valueType == typeof(double)) { NativeQuery.double_not_equal((QueryHandle)queryHandle, columnIndex, (double)value); } else if (valueType == typeof(DateTimeOffset)) { NativeQuery.timestamp_milliseconds_not_equal(queryHandle, columnIndex, ((DateTimeOffset)value).ToRealmUnixTimeMilliseconds()); } else if (valueType == typeof(byte[])) { var buffer = (byte[])value; if (buffer.Length == 0) { // see RealmObject.SetByteArrayValue NativeQuery.binary_not_equal(queryHandle, columnIndex, (IntPtr)0x1, IntPtr.Zero); return; } unsafe { fixed(byte *bufferPtr = (byte[])value) { NativeQuery.binary_not_equal(queryHandle, columnIndex, (IntPtr)bufferPtr, (IntPtr)buffer.LongLength); } } } else { throw new NotImplementedException(); } }
private static void AddQueryNotEqual(QueryHandle queryHandle, string columnName, object value) { var columnIndex = NativeQuery.get_column_index((QueryHandle)queryHandle, columnName, (IntPtr)columnName.Length); var valueType = value.GetType(); if (value.GetType() == typeof(string)) { string valueStr = (string)value; NativeQuery.string_not_equal((QueryHandle)queryHandle, columnIndex, valueStr, (IntPtr)valueStr.Length); } else if (valueType == typeof(bool)) { NativeQuery.bool_not_equal((QueryHandle)queryHandle, columnIndex, MarshalHelpers.BoolToIntPtr((bool)value)); } else if (valueType == typeof(int)) { NativeQuery.int_not_equal((QueryHandle)queryHandle, columnIndex, (IntPtr)((int)value)); } else if (valueType == typeof(float)) { NativeQuery.float_not_equal((QueryHandle)queryHandle, columnIndex, (float)value); } else if (valueType == typeof(double)) { NativeQuery.double_not_equal((QueryHandle)queryHandle, columnIndex, (double)value); } else if (valueType == typeof(DateTimeOffset)) { NativeQuery.datetime_seconds_not_equal(queryHandle, columnIndex, ((DateTimeOffset)value).ToUnixTimeSeconds()); } else { throw new NotImplementedException(); } }