Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

entity framework 4 - many-to-many, poco, ef4 -


i have 3 entities:

goods [gid(pk), goodname] persons [pid(pk), personname] roles [rid(pk), rolename] 

but need associate these object each other. in other words, each can have many persons in many roles. have table in db 3 fields (gid, pid, rid)

for example:

book (gid#1), can have 3 associated persons:  1. jack (pid#1) in role author (rid#1) 2. jack (pid#1) in role editor (rid#2) 3. bill (pid#2) in role painter (rid#3) 

how can map in poco format in entity framework 4?

i believe have create personroles header store person-role relation, access person+role via one:

personroles [prid(pk), personname, rolename] (note: withnow entitykey, relationships, ef eliminate entity , give direct person.roles entity, can access via book.persons.select((p) p.roles)).

personrole#1: jack#1/author#1 personrole#2: jack#1/editor#2 personrole#3: bill#2/painter#3  book.personrole = context.personroles.   singleordefault((pr) => pr.person.personid == 1 && pr.roleid == 1); 

note: main lang vb.net apologize pseudu code above, hope idea.

update

it should like:

<datacontract(isreference:=true)> <knowntype(gettype(good))> <knowntype(gettype(person))> <knowntype(gettype(role))> partial public class goodpersonrole     implements iobjectwithchangetracker     implements inotifypropertychanged  <datamember()> public property goodid() integer             return _goodid     end     set(byval value integer)         if not equals(_goodid, value)             if changetracker.changetrackingenabled andalso changetracker.state <> objectstate.added                 throw new invalidoperationexception("the property 'goodid' part of object's key , cannot changed. changes key properties can made when object not being tracked or in added state.")             end if             if not isdeserializing                 if isnot nothing andalso not equals(good.goodid, value)                     = nothing                 end if             end if             _goodid = value             onpropertychanged("goodid")         end if     end set end property  private _goodid integer   <datamember()> public property good()             return _good     end     set(byval value good)         if _good isnot value             if changetracker.changetrackingenabled andalso changetracker.state <> objectstate.added andalso value isnot nothing                 ' dependent end of identifying relationship, principal end cannot changed if set,                 ' otherwise can set entity primary key same value dependent's foreign key.                 if not equals(goodid, value.goodid)                     throw new invalidoperationexception("the principal end of identifying relationship can changed when dependent end in added state.")                 end if             end if             dim previousvalue = _good             _good = value             fixupgood(previousvalue)             onnavigationpropertychanged("good")         end if     end set end property private _good end class 

(part generated entity ado.net vb poco entity generator)

i copied 'good' id , nav. property should 3 of them.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -