Object store/Database and LINQ

J

jelle79

Hi all,

I'm storing all kind of data stored in objects. Now I want to query my
data-source. And I thought LINQ is the right thing for it.

Data is stored like:

store.Database["%Testtable%"][%RowID%]["%Fieldname%"]

Queries like this work:

var q = from row store.Database["%Testtable%"].Rows
where row.ID == 10
select new { Id = row.ID, Label = row["Label"] };

I want to query my data with a XML-syntax, like:

<data>
<query>
<table name="Testtable" alias="t" />
<table name="Testtable_2" alias="t2" innerjoin="t.ID == t2.ID" />
<where condition="t.ID == 10" />
<field table="t" name="ID" alias="Id" />
<field table="t" name="Label" alias="Label" />
<field table="t2" name="Label" alias="Label" />
</query>
</data>

Do you think this is possible? To parse this XML to a working LINQ-
query? I've tried lots of things, but I cannot get it to work! :S

Hopefully someone can help me. Or if you could suggest me an
alternative, I will think about this too.

Thanks.


Jelle
 
T

Tim Jarvis

<data>
<query>
<table name="Testtable" alias="t" />
<table name="Testtable_2" alias="t2" innerjoin="t.ID == t2.ID" />
<where condition="t.ID == 10" />
<field table="t" name="ID" alias="Id" />
<field table="t" name="Label" alias="Label" />
<field table="t2" name="Label" alias="Label" />
</query>
</data>

Do you think this is possible? To parse this XML to a working LINQ-
query? I've tried lots of things, but I cannot get it to work! :S

Hopefully someone can help me. Or if you could suggest me an
alternative, I will think about this too.

Sure it's possible, what you are asking to do is called a transform,
and you should be able to transform well formed Xml to whatever output
makes sense for you (including Linq statements)

There are a number of transform implementations, and in fact Linq to
XML is regarded as having transform support, the most common transform
implementation is XSLT but I don't think that it would work very well
for you for this (I may be wrong on that though, I am not very familiar
with XSLT functionality), I would be inclined to use Linq to XML.

Note given that what you will be constructing is declarative query
language statements, you may want to investigate compiler writing
techniques (lexical analysis in particular) In fact even just as an
intellectual exercise its very good to understand how this works, I
would recommend the "Purple Dragon Book" for that.
http://www.amazon.com/gp/product/0321486811/

Regards Tim.
 
J

jelle79

I'm sorry, but I think you misunderstood me. I know how to transform
something with XSLT. What I want is to create a processor programm.
This programm will read a XML file like mentioned above. And it will
perform this LINQ-query and give me the outcome.

Is such a thing possible? I've been reading about the Linq.Expression
class...

Thanks.
 

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