You should have another Entity class (probably should be internal) that mirrors your AllowedForums table in the database. Now I'm assuming your User table and your Forums table both have PK/FK relationships to this AllowedForums table. Therefore, there should be an internal property on the User class that looks like this: internal EntitySet AllowedForumsRelationships { get;set; } Or something like that.
This should be on both the User and Forums class. Your AllowedForums class will have two properties on it. One for User and one for Forum.(If you use the LINQ to SQL designer, all this will happen for you automatically) Once you have that, if you want to get all the AllowedForums for a user you can do something like this: public IList AllowedForums { get { var result = new List(); foreach(var relationShip in this.
AllowedForumsRelationships) { result. Add(relationShip. Forum); return result; } } } This is some rough code I just banged out, and I'm not sure it's 100% accurate, but I think you'll get the idea.
Basically you're dealing with a many to many relationship which is always a pain EDIT: I just messed with this idea with the Northwind Database with these tables: Orders OrderDetails Products There's a many to many relationship there: An order can have multiple products, and a product can belong to many orders. Now say you want to get all products for an order: public partial class Order { public IList Products { get { var list = new List(); foreach (var item in this. Order_Details) { list.
Add(item. Product); } return list; } } } That works, so it should work in the scenario you're talking about as well.
You should have another Entity class (probably should be internal) that mirrors your AllowedForums table in the database. Now I'm assuming your User table and your Forums table both have PK/FK relationships to this AllowedForums table. Therefore, there should be an internal property on the User class that looks like this: internal EntitySet AllowedForumsRelationships { get;set; } Or something like that.
This should be on both the User and Forums class. Your AllowedForums class will have two properties on it. One for User and one for Forum.(If you use the LINQ to SQL designer, all this will happen for you automatically).
Once you have that, if you want to get all the AllowedForums for a user you can do something like this: public IList AllowedForums { get { var result = new List(); foreach(var relationShip in this. AllowedForumsRelationships) { result. Add(relationShip.
Forum); return result; } } } This is some rough code I just banged out, and I'm not sure it's 100% accurate, but I think you'll get the idea. Basically you're dealing with a many to many relationship which is always a pain. EDIT: I just messed with this idea with the Northwind Database with these tables: Orders OrderDetails Products There's a many to many relationship there: An order can have multiple products, and a product can belong to many orders.
Now say you want to get all products for an order: public partial class Order { public IList Products { get { var list = new List(); foreach (var item in this. Order_Details) { list. Add(item.
Product); } return list; } } } That works, so it should work in the scenario you're talking about as well.
– Yannick Motton Sep 18 '09 at 17:48 something like get { return from r in AllowerForumsRelationship select r. Forum; } – Yannick Motton Sep 18 '09 at 17:49 I think I have enough to try this out. I'll let you know how it goes.
– Dzejms Sep 18 '09 at 18:55 Iv'e come to the conclusion that I'm in over my head. I'm just going to go with the drag/drop dbml approach.To try your first . Net/OO/C#/Linq/MVC project with full DDD/TDD and all of that is just too much for me.
Gotta ship within a month! So, I do think your answer was correct and I've given you the vote. Thanks for your help.
Maybe in a few months I'll refactor and give it another go. – Dzejms Sep 18 '09 at 17:22.
Something like: var AllowedForums = from f in ForumsTable join af in AllowedForumsTable on f. Id equals af. Forumid into temp from aft in temp.DefaultIfEmpty() where (f.
IsGlobal == 1 || aft. Userid == 1) select f.
You should have another Entity class (probably should be internal) that mirrors your AllowedForums table in the database. Now I'm assuming your User table and your Forums table both have PK/FK relationships to this AllowedForums table. Or something like that.
This should be on both the User and Forums class.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.