internal bool Read(object[] primaryKeys) { if (primaryKeys.Length == 0) { throw new CSException("Read() requires parameters"); } Initialize(); CSStringCollection columnNames = new CSStringCollection(); List <object> keyValues = new List <object>(); if (primaryKeys.Length != _schema.KeyColumns.Count) { throw new CSException(GetType().Name + ".Read(..keys..) called with " + primaryKeys.Length + " parameters, but there are " + _schema.KeyColumns.Count + " key fields defined"); } for (int i = 0; i < primaryKeys.Length; i++) { columnNames.Add(_schema.KeyColumns[i].Name); keyValues.Add(primaryKeys[i]); } if (!ReadFields(_schema.ColumnsToRead, columnNames, keyValues)) { return(false); } _dataState = CSObjectDataState.Loaded; Fire_ObjectRead(); return(true); }
private bool ReadFields(CSStringCollection columnList) { CSStringCollection keyList = new CSStringCollection(); List <object> valueList = new List <object>(); foreach (CSSchemaColumn schemaColumn in _schema.Columns) { if (schemaColumn.IsKey) { keyList.Add(schemaColumn.Name); valueList.Add(_fieldData["#" + schemaColumn.Name].ValueDirect); } } return(ReadFields(columnList, keyList, valueList)); }
private void CreateColumnsToRead() { _columnsToRead.Clear(); foreach (CSSchemaColumn schemaColumn in Columns) { if (schemaColumn.MappedField != null && schemaColumn.MappedField.Lazy) { continue; } _columnsToRead.Add(schemaColumn.Name); } if (_columnsToRead.Count < 1) { throw new CSException(string.Format("No data fields mapped or primary key is lazy for object type <{0}>", ClassType.Name)); } }