Question: I am using C++ under Ubuntu 11.10 and the latest version of NetBeans. Let's say I have the 
following code:

```
class Node {}
class DerivedNode : public Node {}

class Graph {
    vector<Node*> nodes;
}

class DerivedGraph : public Graph { }

```

At the moment I'm storing DerivedNodes in the DerivedGraph class like this for example:

```
nodes.push_back(new DerivedNode());

```

When I need to use specific methods that only apply to DerivedNodes and DerivedGraphs 
I am forced to use a dynamic\_cast on my Node pointers first.

I would like to be able to have specific methods in DerivedGraph which apply only to DerivedNodes
and avoid the need of casting pointers. I do not mind having to redesign my classes if the end
result is better than what I have.

I am sure there must be a clean and simple method to achieve the same thing I'm trying to do.
Maybe something with specialized templates? Any thoughts on the matter would be greatly 
appreciated. I'll also provide any additional information required in the case I haven't been too
clear.

EDIT: I don't have two copies. I wanted to put emphasis on how it looks. I apologize for the presentation. What I want to obtain is:

```
class DerivedGraph: public Graph {
    vector<DerivedNode*> nodes;
}    

```

Answer: 
Obviously you're not pointing to the right database, or your don't have a user name with that password (I'm guessing the encrypted password doesn't match what's in the DB. Try using FirstOrDefault(), then you can check for Null if the password is wrong...
Check if your class has the proper attributes that tell Linq to SQL how to match it against a database table.

Your class should have 

```
[Table(Name="Nombres")]

```

attribute, and properties should have

```
[Column]

```

attributes, some should also be primary keys etc.

If you don't already have this, I suggest you generate the class using the Entity Class Generation tool: <http://msdn.microsoft.com/en-us/library/bb425822.aspx#linqtosql_topic32>