pass different LINQ objects (by string name?) to the same(form-)constructor

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lextendo

    pass different LINQ objects (by string name?) to the same(form-)constructor

    Hi,

    This is what I want to achieve:
    I hav a lookup-form used by different parent forms to present a
    database table. So form X uses the lookup to search table tblA, form Y
    uses the lookup to search tblB.

    The data in the lookup form is fetched using a linq to sql context
    class and its containing object, so each parent form should pass the
    required context class to the lookup form. I tried the approach of
    sending the datacontext and recordobject class string names to the
    lookup form constructor

    So this specific tblRole query:
    ExampleProject. Database.RoleDa taContext _db = new
    ExampleProject. Database.RoleDa taContext();
    var RoleList =
    from Role in
    _db.GetTable<Ex ampleProject.Da tabase.tblRole> ()
    select new { Role.RoleID, Rol.RoleDescrip tion };

    Should be something generic like

    [?contextObject?] _db = new [?contextObject?] ();
    var ObjectList =
    from MyObject in _db.GetTable<[?recordObject?]>()
    select new { MyObject.[?MyObjectID?], Object.[?
    MyObjectDescrip tion?]};


    The ID and Description are always tablenameID and
    tablenameDescri ption. In fact all the supporting tables approached by
    the lookup form will have the same structure.
    The data is then presented in a grid, where the ID is returned to the
    parent when the user selects a record.

    So two questions:
    1 Am I on the right track here, or is this not a viable solution
    (passing the stringname of the context/recordobject)
    2 How can it be done (example code would be very much appreciated ;)

    regards,
    Alex

Working...