/// <summary> /// Returns whether an Entity exists in the database, by comparing its /// Primary/Composite Key(s). /// </summary> /// <param name="obj"></param> /// <returns></returns> public bool Contains(TEntity obj) { // Create a WHERE statement WhereStatement where = new WhereStatement(Context); // build the where statement, using primary keys foreach (string keyName in EntityTable.PrimaryKeys) { PropertyInfo info = EntityTable.Columns[keyName].Property; object val = info.GetValue(obj); // Add value to where statement where.And(keyName, Comparison.Equals, val); } return(Contains(EntityTable.TableName, where)); }