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.

c# - Fluent NHibernate and friend relationship -


i need model friend relationship fluent nhibernate. company model has list<company> related related companies. relations between companies modeled in database in table, related looks this:

customer_id | related_id

both columns foreign key pk in customers table.

the problem relations saved once each pair (do call bi-directional?).

i'm able change table structure if it's easier solve in way.

i need map fluent nhibernate when customer.related(), generates query like:

select * companies left join related on customer_id = id or related_id = id 

i've tried map in number of different ways, closest i've tried is:

hasmanytomany(x => x.related)        .inverse()        .parentkeycolumn("customer_id")        .childkeycolumn("related_id")        .table("relations")        .cascade.all(); 

however, (of course) maps when customer_id matches.

how solve this?

edit: think it's similar fluent nhibernate: how create one-to-many bidirectional mapping?, not me much.

i think want achieve half way done. you've mapped 2 entities many2many relation already. wouldn't touch mapping further.

instead query want thru mapping. this.

function getrelated(long id){     return session.query<related>()                  .where(r=>r.customer.id == id || r.related.id == id)                  .tolist();  } 

a reccomendation tho, mapped entity's name related , have related field might sound confusing, i'd suggest rename else (if possible).

hope helps.


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 -