Reputation: 293
I guess the title was not very clear, but what I want to do is this:
Im using .net framework 3.5 and a asp.net web app.
I have 2 tables in my db:
tb_provider():
provider_id
provider_name
tb_demand:
demand_id(pk)
demanda_name
cod_provider(fk)
its a one to many relationship.
1 provider may have many demands
1 demand is related to only one provider.
so I have created theses classes:
public class ProviderVO
{
public int Id_Provider{ get; set; }
public string Name_Provider { get; set; }
public List<DemandVO> List_Demand{ get; set; }
}
public class DemandVO
{
public int Id_Demand{ get; set; }
public string Name_Demand{ get; set; }
public ProviderVO objProvider{ get; set; }
}
I put a Demand list in the provider class so I could get all the demands related to that provider.
The same goes for the demand class. Im trying to relate the demand with its provider object.
Am I thinking right?
The reason for all this is because I could not the providers plus its demands in a gridview with a linq to entities query.
So I thought something could be wrong in my classes.
thx!
Upvotes: 0
Views: 73
Reputation: 364249
Actually whole your code is wrong. .NET 3.5 supports only EFv1 and EFv1 doesn't have built in support for POCO classes. The best way to solve your problem is adding EDMX file and let VS generate classes which can be used with EFv1. Those classes will inherit from EntityObject
and contain a lot of additional properties. Also your navigation properties will use different types.
Alternative solution is upgrading to .NET 4 and EFv4+ where your code will work when correctly mapped.
Upvotes: 3