C# and DLINQ

THT

THT

Associate
Joined
10 Mar 2004
Posts
998
Anyone had much luck with this?

The actually mapped linked stuff is fine.
Im struggling with an "Old fashioned SQL" statement using ExecuteQuery()

Code:
 String FieldList = db.ExecuteQuery<String>("select FieldList from Table where SearchId = 15").Single();
            String WhereClause = db.ExecuteQuery<String>("select WhereClause from Table where SearchId = 15").Single();

            String sql = "select " + FieldList + " from Table2 where " + WhereClause;
            
            
            var a = db.ExecuteQuery(sql).ToList(); [COLOR="Red"] <--FAILS HERE[/COLOR]

It wants me to type the return, but i dont know the type, as its a dynamically created query.....
 
SQL queries return an integer which signifies whether the query was successful or not.
This might be what it needs.
Is there a db.ExecuteNonQuery() method? - just noticed I didn't read the question properly.
I know nothing about linq.
 
Last edited:
I haven't had too much experience with DLINQ, but I thought the point of it was that it automatically casts your query result to an IEnumerable<T> type, where T is the particular object you're returning with your query.

I guess you might be able to use a IEnumerable<Object> if you don't know the type you'll be returning, but it really loses the point of having the generic stuff there.

Code:
var a = db.ExecuteQuery<Object>(sql).ToList();

That should give you something of type IEnumerable<Object>, but you'll still need to know what type it should be do cast it and do anything with it.

EDIT: Thinking about it, I'm not even sure this would work as Object isn't an entity you have defined so I don't know how it would handle that.
Why do you need to do this with DLINQ anyway? It seems that what you want is ill-suited to the capabilities of the technology you're using.
 
Last edited:
Yeah I tried Object already.

The problem is because the data is coming from multiple tables, I cant Strongly Type it with <TableName>
You are right, becuase ive been using DLINQ elsewhere in the project, i was trying not to mix technologies.

Ill be using OleDB for this

Thanks
 
Back
Top Bottom