private (string, object) SQLGetOperatorAndOperand(Data.Models.Attribute attribute) { if (attribute.type == "string" && string.IsNullOrEmpty(attribute.format)) { // Two comparison operators are applicable to simple text comparisons; // o "==" yields True if the string value(as per XPath) of any // selected node matches the argument; otherwise False. // o "!=" yields True if the string value of every selected node does // not match the argument; otherwise False. if (_comparison == "==") { if (_argument.StartsWith("*") || _argument.EndsWith("*")) { return("LIKE", SQLGetStringValue()); } else { return("=", SQLGetStringValue()); } } else if (_comparison == "!=") { if (_argument.StartsWith("*") || _argument.EndsWith("*")) { return("NOT LIKE", SQLGetStringValue()); } else { return("<>", SQLGetStringValue()); } } } else if (attribute.type == "string" && attribute.format == "0xbyte") { try { var value = _argument.UnHex(); return(SQLGetGenericOperator(), value); } catch (FIQLException) { throw; } catch { throw new FIQLException("Value for attribute " + _selector + " is not a 0xbyte : " + _argument + "."); } } else if (attribute.type == "string" && attribute.format == "byte") { try { var value = Convert.FromBase64String(_argument); return(SQLGetGenericOperator(), value); } catch (FIQLException) { throw; } catch { throw new FIQLException("Value for attribute " + _selector + " is not a byte : " + _argument + "."); } } else if (attribute.type == "string" && attribute.format == "date-time") { try { var value = _argument.UnISO8601(); return(SQLGetGenericOperator(), value); } catch (FIQLException) { throw; } catch { throw new FIQLException("Value for attribute " + _selector + " is not a date-time : " + _argument + "."); } } else if (attribute.type == "string" && attribute.format == "date") { try { var value = _argument.UnISO8601(); return(SQLGetGenericOperator(), value); } catch (FIQLException) { throw; } catch { throw new FIQLException("Value for attribute " + _selector + " is not a date-time : " + _argument + "."); } } else if (attribute.type == "integer") { try { var value = long.Parse(_argument); return(SQLGetGenericOperator(), value); } catch (FIQLException) { throw; } catch { throw new FIQLException("Value for attribute " + _selector + " is not an integer : " + _argument + "."); } } else if (attribute.type == "number") { try { var value = System.Decimal.Parse(_argument); return(SQLGetGenericOperator(), value); } catch (FIQLException) { throw; } catch { throw new FIQLException("Value for attribute " + _selector + " is not a number : " + _argument + "."); } } else if (attribute.type == "boolean") { if (_argument.ToLower().Equals("true")) { return(SQLGetGenericOperator(), "1"); } else if (_argument.ToLower().Equals("false")) { return(SQLGetGenericOperator(), "0"); } else { throw new FIQLException("Value for attribute " + _selector + " is not a boolean : " + _argument + "."); } } throw new FIQLException("Attribute which type is " + attribute.type + " can't be handled."); }
public CreateViewModel() { Attribute = new Data.Models.Attribute(); }
private string SQLGetColumnName(Data.Models.Attribute attribute) { return(attribute.columnname); }
public EditViewModel() { Attribute = new Data.Models.Attribute(); }