asp.net mvc 3 - MVC3- Controller acces to several tables -
i new mvc, in following text may confusing :d can tell me, how write controller database tables following code in models:
public class kniha //in translate=book { public int knihaid { get; set; } [maxlength(100, errormessage="text knihy muze byt dlouhy max 100 znaku")] public string nazevknihy { get; set; } public datetime datumvydani { get; set; } public string popisknihy { get; set; } public int pocetstran { get; set; } public int pocetkapitol { get; set; } public int autorid { get; set; } public virtual autor autor { get; set; } public virtual icollection<zanr> knihazanry { get; set; } public virtual icollection<cenik> knihaceniky { get; set; } } public class autor //in translate= author { public int autorid { get; set; } public string jmeno { get; set; } public string heslo { get; set; } public string prijmeni { get; set; } public string stat { get; set; } public string mesto { get; set; } public string ulice { get; set; } public datetime datumnarozeni { get; set; } public int telefonicislo { get; set; } public string email { get; set; } public string konto { get; set; } public string celejmeno { { return jmeno + " " + prijmeni; } } public virtual icollection<kniha> napsaneknihy { get; set; } } public class cenik //in translate=price { public int cenikid { get; set; } public int aktualnicena { get; set; } public datetime datumceny { get; set; } public kniha kniha { get; set; } public virtual zamestnanec zamestnanec { get; set; } public int zamestnanecid { get; set; } public int knihaid { get; set; } } public class zanr //in translate=genre { public int zanrid { get; set; } [maxlength(50, errormessage="maximalni delka 50 znaku!!")] public string nazevzanru { get; set; } public virtual icollection<kniha> zanrknihy { get; set; } } public class autorknihadalsi { public ienumerable<autor> autori { get; set; } public ienumerable<kniha> knihy { get; set; } public ienumerable<zanr> zanry { get; set; } public ienumerable<cenik> ceniky { get; set; } } this controller, doesnt work:
public actionresult index() { var viewinfo = new autorknihadalsi(); viewinfo.knihy = db.knihy.include(c => c.autor).include(i=> i.knihaceniky.select(c=> c.aktualnicena)); return view(viewinfo); } i wanted print information books. in every book wanted print author, actual price , genre. dont know, how controller this. secondly want ask how execute saved t-sql procedures on server( found informations here on web, did not help). edit: tables complete
Comments
Post a Comment