Query GetPkQuery() { var q = new Query(new QTable(TableName, null)); var grpAnd = QGroupNode.And(); q.Condition = grpAnd; foreach (var pkCol in RS.PrimaryKey) { grpAnd.Nodes.Add((QField)pkCol.Name == new QVar(pkCol.Name).Set(null)); } return(q); }
Query GetQueryByKey(object pocoModel) { var schema = DataMapper.Instance.GetSchema(pocoModel.GetType()); if (schema.Key.Length == 0) { throw new ArgumentException("Specified object doesn't have properties annotated with KeyAttribute."); } var q = new Query(schema.TableName); var andGroup = QGroupNode.And(); q.Condition = andGroup; for (int i = 0; i < schema.Key.Length; i++) { var keyCol = schema.Key[i]; if (keyCol.GetVal != null) { andGroup.Nodes.Add((QField)keyCol.ColumnName == new QConst(keyCol.GetVal(pocoModel))); } } return(q); }