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 Inheritance -


i have looked @ several possible solutions issue did not find right one.

i need full set, is, need fetch types of base type. i.e. actionhistory type, others, inherit actionhistory base class. problem was getting entities of actionupdate type did not have actionupdatedetails collection filled.

my problem unable retrieve actionupdatedetails data within derived actionupdate class.

there 3 classes in model:

public class actionhistory { public int id {get;set;} }  public class actionupdate : actionhistory { public icollection<actionupdatedetail> actionupdatedetails{get;set;} }  public class actionupdatedetail { int id{get;set;} public string field{get;set;} public string value{get;set;} } 

i tried implementing solution suggestion: entity framework: inheritance , include

like this:

var result = actionhistory in actionhistories select new { actionhistory, actionupdatedetails = actionhistory actionupdate ?  (actionhistory actionupdate).actionupdatedetails : null }; 

all exception message:

unable create constant value of type 'system.collections.generic.icollection`1'. primitive types ('such int32, string, , guid') supported in context.

then tried simulate situation outside ef , worked. using poco model , have extracted involved classes separate project, filled structure sample data, , tested success, i.e. actionupdatedetails collection filled data.

any on appreciated!

n.

with regards answer, actually, correct way use oftype<t>:

var actionupdatedetails = ctx.actionhistories                        .oftype<actionupdate>()                        .select(x => x.actionupdatedetails)                        .tolist(); 

this causes database-side filter (inner join), whereas solution performs implicit casting on items may not of type - in case null reference exception.


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 -