Dynamic LINQ ITable

Tech-Archive recommends: Fix windows errors by optimizing your registry



Problem: We enable our clients to create custom fields they wish to collect. We want to use Dynamic LINQ to query this table (Just one).
My initial post and suggestion(s) are here: http://shrinkster.com/tzp

So I have a class called "ClientTable". All tables have some common fields, but I need to add more at runtime.
Now I have a class that looks like:
--------------------
[Table(Name="ClientTable")]
public class ClientTable{
[Column(DbType = "VarChar(400) NOT NULL")]
public string FirstName { get; set; }
}
--------------------

Now this works great in dynamic LINQ when I do something like:
--------------------
Table<ClientTable> table = db.GetTable(typeof(ClientTable));
table.Where("FirstName == @0", "Bill");
--------------------

But if a client has a column in that table called "Age" I can't do something like:
--------------------
table.Where("Age > @0", 30);
--------------------
I get an error saying that "Age" doesn't exist, even though it exists in the database. If I add the one Age property it works fine (which is understandable).
So now, how can I dynamically add properties to ClientTable class at runtime?

Is there a way to do something like this:
--------------------
Table<ClientTable> table = db.GetTable(typeof(Facade.CreateDynamicType))) as Table<ClientTable>;
--------------------

As I'm sure you know the problem is the typeof(Facade.CreateDynamicType)
because "CreateDynamicType" is a property and not a class.
I've tried some quick tests by making the CreateDynamicType a method that
returns a Type and other stupid ideas that just didn't work.

Can something like this be done, should I pursue a solution to my problem this way or should I just stick to a normal method like the:
Table<ClientTable> table = db.GetTable(typeof(ClientTable));
and then try to dynamically destory and create a new "ClientTable" object at runtime?

Can I delete a type then create a new one on the fly? Any suggestions?

.



Relevant Pages

  • RE: Dynamic LINQ ITable
    ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ... Subject: Dynamic LINQ ITable ... We enable our clients to create custom fields they wish to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: data calculated in form field not showing up on table datasheet
    ... I have a Clients form that I fill out, and it puts the information in my ... calculated a client's age from data in a Date of Birth field and Admission ... here is my code that is in the Control Source property of the Age At ...
    (microsoft.public.access.forms)
  • Ageism
    ... Birth a mandatory field on their on-line application forms? ... I do, as "un homme d'un certain age", have something at stake here. ... whether they pass this info on to the clients who then apply their own ... discrimination. ...
    (uk.consultants)
  • Re: analysising ages in database.
    ... Doug Steele, Microsoft Access MVP ... >I have a list of clients all with dates of birth. ... > I can create a querry that will calculate their exact ages fine but I ... The type where age is the X ...
    (microsoft.public.access.queries)
  • Re: Criteria to decide what is private?
    ... of an invariant being exposed or not? ... The invariant is exposed to clients (which I'm reading as ... fault for not having a correct specification of its class. ...
    (comp.object)