Linq without DBML

D

David

Hi all,

I am still new to Linq and rapidly making progress.

I need to be able to work with a DB table without knowing beforehand (at the
app development stage) what the table name is (or even the DB). I need it to
be quite generic.

So, I can get the connectionstring, dbname, table name from a config file.
Once I have that, I can then use sql commands to get the field names (or
even use some other methods of getting the field names).

But, from what I have learned with linq so far, I need a DBML file. As I
understand, this describes the table.

Is there anyway that I can use linq on the fly to work with the table, or
will I be best reverting back to standard SQL to manage this?

Any pointers to websites or sample code on working with linq on tables that
I don't neccesarily yet know the details of (except for its dbname, name and
connstring) would be very much appreciated.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
P

Pavel Minaev

Hi all,

I am still new to Linq and rapidly making progress.

I need to be able to work with a DB table without knowing beforehand (at the
app development stage) what the table name is (or even the DB). I need itto
be quite generic.

So, I can get the connectionstring, dbname, table name from a config file..
Once I have that, I can then use sql commands to get the field names (or
even use some other methods of getting the field names).

This sort of thing is precisely when you do not need LINQ (at least
not the kind of LINQ that is translated to SQL).

One of the major points of LINQ to SQL is that it does static type
checking of your schema, because you're dealing with strongly typed
entity objects, not with strings as table/field names. And here, you
need the opposite.
 
D

David

Hi,

Thanks for the response.

So, in order for me to make this work, I have to revert to sqlcommand?

Not a problem, though a bit of a shortcoming if you ask me.

(There are quite a few times, especially with websites, where I have a long
update to a table (for example, filling a shop basket system from an excel
file) and don't want the live site to be down during the update. I create an
offline table, populate that, then swap out the live table for the offline
table. I guess Linq can't cope with that either.)

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


Hi all,

I am still new to Linq and rapidly making progress.

I need to be able to work with a DB table without knowing beforehand (at
the
app development stage) what the table name is (or even the DB). I need it
to
be quite generic.

So, I can get the connectionstring, dbname, table name from a config file.
Once I have that, I can then use sql commands to get the field names (or
even use some other methods of getting the field names).

This sort of thing is precisely when you do not need LINQ (at least
not the kind of LINQ that is translated to SQL).

One of the major points of LINQ to SQL is that it does static type
checking of your schema, because you're dealing with strongly typed
entity objects, not with strings as table/field names. And here, you
need the opposite.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top