ASP.Net Dynamic Data - Show Columns from Two Tables as Single Entity -


i have created new c# asp.net dynamic data website provides crud functionality table entities in edmx file.

the following tables in file :

customers ----------- customerid  customername   documents ----------- documentid documentname documenttype customerid  

where customerid pk in customers , fk in documents. when dynamic web app displays rows in documents want display following columns in gridview:

documents ----------- documentid documentname documenttype customerid  customername 

its important when user sees list of documents can see customername associated each document. not want edit customername documents list. viewing. how can see customername document gridview in dynamic data web app?

i used code first database vs2012, here entities generated ef :

namespace docmappings {     using system;     using system.collections.generic;      public partial class customers     {         public customers()         {             this.documents = new hashset<documents >();         }          public int customerid { get; set; }         public string customername { get; set; }           public virtual icollection<documents> documents { get; set; }     }  } 

and documents entity is:

namespace docmappings {     using system;     using system.collections.generic;      public partial class documents     {                     public int documentid { get; set; }         public string documentname { get; set; }         public int documenttype{ get; set; }         public int customerid { get; set; }           public virtual customers customers { get; set; }              } } 

you can create anonymous type data:

var docs = context.documents.selectmany(d => new      {         d.documentid,         d.documentname,         d.documenttype,         d.customerid,         d.customer.customername      }); 

alternatively, preferable put concrete class:

public class customerdocument {     public int documentid { get; set; }     public string documentname { get; set; }     public int documenttype { get; set; }     public int customerid { get; set; }     public string customername  { get; set; } } 

and data slight modification:

list<customerdocument> docs = context.documents.selectmany(d => new customerdocument     {         d.documentid,         d.documentname,         d.documenttype,         d.customerid,         d.customer.customername      }); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -