protected void CheckUnassignedRead(Row row) { if (row == null) { throw new ArgumentNullException("row"); } if (!row.tracking) { return; } if (!row.trackWithChecks) { return; } if (row.IsAssigned(this)) { return; } if (!this.GetIsNull(row)) { return; } throw new InvalidOperationException(String.Format( "{0} field on {1} is read before assigned a value!", this.Name, row.GetType().Name)); }
protected void CheckUnassignedRead(Row row) { if (row == null) { throw new ArgumentNullException("row"); } if (!row.tracking) { return; } if (!row.trackWithChecks) { return; } if (row.IsAssigned(this)) { return; } if (!this.GetIsNull(row)) { return; } throw new InvalidOperationException(String.Format( "{0} field on {1} is read before assigned a value! Make sure this field is selected in your SqlQuery. Extensions like connection.List only loads table fields by default, view / expression fields are not loaded unless explicitly selected.", this.Name, row.GetType().Name)); }
/// <summary> /// Adds all field values in a row to where clause with equality operator and auto named parameters /// (field name prefixed with '@').</summary> /// <param field="row"> /// The row with modified field values to be added to the where clause (key row). Must be in TrackAssignments mode, /// or an exception is raised.</param> /// <returns> /// Object itself.</returns> public static T WhereEqual <T>(this T self, Row row) where T : IFilterableQuery { if (row == null) { throw new ArgumentNullException("row"); } if (!row.TrackAssignments) { throw new ArgumentException("row must be in TrackAssignments mode to determine modified fields."); } foreach (var field in row.GetFields()) { if (row.IsAssigned(field)) { self.Where(new Criteria(field) == self.AddParam(field.AsObject(row))); } } return(self); }
/// <summary> /// Sets all field values in a row with auto named parameters (field name prefixed with '@').</summary> /// <param field="row"> /// The row with modified field values. Must be in TrackAssignments mode, or an exception is raised.</param> /// <returns> /// Object itself.</returns> public static T Set <T>(this T self, Row row, IField exclude = null) where T : ISetFieldByStatement { if (row == null) { throw new ArgumentNullException("row"); } if (!row.TrackAssignments) { throw new ArgumentException("row must be in TrackAssignments mode to determine modified fields."); } foreach (var field in row.GetFields()) { if (!ReferenceEquals(field, exclude) && row.IsAssigned(field)) { self.Set((IField)field, field.AsObject(row)); } } return(self); }
protected void CheckUnassignedRead(Row row) { if (row == null) throw new ArgumentNullException("row"); if (!row.tracking) return; if (!row.trackWithChecks) return; if (row.IsAssigned(this)) return; if (!this.GetIsNull(row)) return; throw new InvalidOperationException(String.Format( "{0} field on {1} is read before assigned a value!", this.Name, row.GetType().Name)); }