Sunday 15 June 2014

wpf - C# Generic Table from DataContext -



wpf - C# Generic Table from DataContext -

i'm attempting create generic wpf form or page, when called, load in info linq table. here concept:

i have 3 tables in linq datacontext identical (apart info within)

typeid , type columns

i generically pass info in tables sec form depending on table user selects (essentially can narrow downwards list of objects of said type.

i've seen responses, (in particular accepted reply 1 linq query generic table) close looking for, not quite. 1 issue have above reply t must reference type.

i've done more searching , found more answers like:

someclass<t> : <t> t

but unfortunately these farther own context , unable bridge 2 concepts of happening. below have posted hope do.

somedatacontext db = new somedatacontext(); private void pageloader<t>(){ newpage n = new newpage(t) //this hoping pass table(s) constructor. }

and here constructor:

newpage(t){ listbox l = new listbox(); l.datasource = t; }

any assistance in direction helpful (besides msdn, please. i've been there , i'm still lost.)

let start top. linq simply abbreviation language integrated query. interchangeable lambda. different syntax both accomplish same task. querying collection or datasource. see http://msdn.microsoft.com/en-ca/library/bb397926.aspx

you referring entityframework code first approach of creating database. linq simply way access , manipulate info within.

with out of way, pointing out generic method , generic class. t standard naming convention generic type. utilize representation like. if going passing in entities, might utilize tentity example.

see http://www.dotnetperls.com/generic-method http://www.dotnetperls.com/generic

when see someclass t, constraint type parameters.

and finally, have been waiting for...

https://codereview.stackexchange.com/questions/19037/entity-framework-generic-repository-pattern

the next should set on right path.

http://blog.gauffin.org/2013/01/repository-pattern-done-right/ <- more of improve starting tutorial

c# wpf generic-collections

No comments:

Post a Comment