internal void Reset() { _WeakReference = null; _State = KMaps.MetaState.Empty; // By default... _Map = null; _Record = null; // Do not dispose, might be in use elsewhere... }
internal static void ClearMap( IKMap map ) { if( map == null ) throw new ArgumentNullException( "map", "Map cannot be null." ); lock( _SyncRoot ) { int count = _MetaEntities.Count; for( int i = 0; i < count; i++ ) { var meta = _MetaEntities[i]; if( meta._Map == map ) { _MetaEntities.RemoveAt( i ); count--; i--; } } } }
internal static KMetaEntity First( IKMap map, params Func<dynamic, object>[] specs ) { if( map == null ) throw new ArgumentNullException( "map", "Map cannot be null." ); if( specs == null ) throw new ArgumentNullException( "specs", "Specifications cannot be null." ); if( specs.Length == 0 ) throw new ArgumentException( "Specifications list is empty." ); KRecordBuilder builder = new KRecordBuilder( map.Link.DbCaseSensitiveNames ); foreach( var spec in specs ) builder.Add( spec ); KRecord find = builder.Generate( autoDispose: true ); var r = First( map, find ); find.Schema.Dispose(); find.Dispose(); return r; }
internal void InsertOn( IKMap map ) { if( map == null ) throw new ArgumentNullException( "map", "Map cannot be null." ); if( this._Map != null ) throw new InvalidOperationException( "This MetaEntity already belongs to other map: " + this ); lock( _SyncRoot ) { this._Map = map; _MetaEntities.Add( this ); } }
// -------------------------------------------------- internal static KMetaEntity First( IKMap map, KRecord find ) { if( map == null ) throw new ArgumentNullException( "map", "Map cannot be null." ); if( find == null ) throw new ArgumentNullException( "find", "KRecord cannot be null." ); if( find.Count == 0 ) throw new ArgumentException( "Find record contains no columns." ); lock( _SyncRoot ) { foreach( var meta in _MetaEntities ) { if( meta.Host == null ) continue; if( meta.Record == null ) continue; if( meta.Map != map ) continue; if( !find.EquivalentTo( meta.Record, strict: false ) ) continue; return meta; } } return null; }