473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Dynamic LINQ ITable

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<ClientTabletable = 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<ClientTabletable = 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<ClientTabletable = 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?

Jan 18 '08 #1
0 3172

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ronald S. Cook | last post by:
I've always been taught that stored procedures are better than writing SQL in client code for a number of reasons: - runs faster as is compiled and lives on the database server - is the more...
11
by: =?Utf-8?B?U3RlZmFuIFdpbGhlbG0=?= | last post by:
Hello, played a little with orcas and went into a problem by building dynamic queries. I want to build a dynamic where clause but only with parameters that are not empty =(TextBox.Text != "")....
15
by: EDBrian | last post by:
My problem is this. Our clients create different fields they want to collect and we allow them build dynamic filters, reports etc... We run some TSQL to actually create the column and all works...
1
by: Lacutas | last post by:
Hi I'm having some problems getting a dynamic LINQ query to work on my DataSet. The idea is that a user selects certain criteria, and then the LINQ query filters through the dataset making the...
1
by: john | last post by:
I'm trying to build a LINQ expression that will use a dynamic construction of a LIKE statement in the WHERE clause, it would look something like this in SQL: WHERE TaskGroup Like "*00*" OR...
10
by: Jonathan | last post by:
Hi all, I have a file consisting fixed width records from which I need to extract only those lines meeting certain conditions. These conditions do change and I find myself recoding/compiling...
2
by: Mucahit ikiz | last post by:
I cant make a full dynamic query in LINQ I have 2 situation methods (only_exp_query, only_tbl_query) those are working. .... using System.Linq.Dynamic; using System.Data.Linq; .... string...
4
by: acgritt | last post by:
I am looking for some information on if it is possible/how to create a dynamic XLinq statement. I know for Linq to SQL you can do the following: var query = db.Customers. Where("City = @0 and...
4
by: Andrus | last post by:
Checking Client-only framework subset in VS2008 SP1 project properties causes in my application compile error The type 'System.Data.Linq.ITable' is defined in an assembly that is not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.