Mysql-specific query in SubSonic - subsonic

I'd like to add a query to my SubSonic DAL that uses the MySQL fulltext search construct "WHERE MATCH (columnlist) AGAINST (searchterm)", but can't find an equivalent in SubSonic.
Is there a way of using Subsonic to execute a "literal" query - i.e. it just queries with the exact MySQl code I feed it?
Alternatively, could I implement a subclass of SubSonic.Where to run the fulltext search? If so, how would I go about this?
I'm using SubSonic 2.x. Any ideas welcome. Thanks.
ddoctor

You can use CodingHorror to run any SQL you like.

Related

Search over multicore index without same schema solr

I use Solr, and i would like to know if i can search over multiple index using multicore. I know there is "Distributed Search" but i think it's only for index with same schema.
Thanks.
no we can search with different schema also but only thing is it will search in common field..See this for more information .
Further for manipulation we can use solrj. else if only in solr .. read about Core Admin Handler
let me know if you need any help further.

How to use SubSonic SimpleRepository with NON Plural Table Names

I have found out that SubSonic SimpleRepository expectes plural table names however I have started working on a database that doesn't have this and I am unable to change the table names.
Is there a way I can use Subsonic without making database changes?
I have seen one suggestion but I don't fancy that too much.
I'm not tied to using the SimpleRepository I just thought it would be easiest as I need the ability to swap database connections (SQL & Oracle) based on the clients requirements. The schema is the same on both. With SimpleRepository I can just swap out the connection string in the web.config.
You can apply the SubSonicTableNameOverride attribute on your classes you use with Simple Repo and use an arbitrary table name!

SubSonic 2.x Substring of a column

How do I write a SubSonic query similar to this is C#.net:
SELECT * FROM Users WHERE substr(last_name,1,1) = 'S';
I don't want to use "LIKE" it eats up performance.
Don't think you can do this, you can use subsonic to execute the query itself though.
How to here:
http://subsonicproject.com/docs/CodingHorror

Subsonic 2.2 InnerJoin Across Two Databases

Can anyone provide an example of how to join across two schemas using subsonic 2.2.
This doesn't work:
SqlQuery qu = new Select("*")
.From(NorthwindLeads.Lead.Schema)
.InnerJoin(Northwind.StatsMap.SourceIdColumn, NorthwindLeads.Lead.SourceIdColumn);
There's no easy way to do this in subsonic that I'm aware of. I would recommend adding a view to your database which returns the data you want from the other schema and then joining to the view in your subsonic query.

Debug a Subsonic Select Query

I've got a Subsonic query that isn't returning any values. I think the problem is in my where clause, although I'm not sure why.
What I'm really looking for is a way to debug the query to see the SQL that's actually being spit out by Subsonic. I know there was a way to do this with the Query object with Inspect(), but I'm using Select objects (or could also probably use SQLQuerys) because I need joins. Is there any inspect() type option for a Subsonic Select?
Here's the code I'm using:
Dim qry As New [Select]("Contract_NO")
qry.From(<table1>.Schema)
qry.InnerJoin(<table2>.<table2columnA>, <table1>.<table1columnA)
qry.Where(NonInfoleaseLessor.Columns.LessorCode).Like("mystring")
If I comment out the where line, I get a full list of results. It doesn't like something about it, but I've manually run the query at the database with that where clause, and it works. How can I see what the difference is?
The problem with your query is that you should be using Contains("mystring") instead of Like("mystring").
The best way to see the SQL is to use the BuildSqlStatement() method of the query.
Use [a] profiler to see what SQL is actually being executed against the database.
As Adam spotted:
.Like("mystring")
should most probably be
.Like("%mystring%")
please try using Like("%mystring%")
It might have something to do with your choice of clause, or which column name you are using. Subsonic has a couple of column name field
OBJECT.xyzColumn
OBJECT.xyzColumn.QualifiedName
OBJECT.Columns.xyz
I have had to play with these in the past to get the values I wanted.

Resources