I want to no if there any way to add an "Having" constrain to an aggregation select?
Example: if i need all sales sum by date having the sales sum > 1000.
Best Regards,
TheGodfather
SubSonic does have a "having" but you don't explicitly state it.
It is determined from you selecting an Aggregate and adding the Aggregate to the Where clause.
For example (paraphrased from SubSonic AggregateTests.cs)
SubSonic.SqlQuery q = new
Select(Aggregate.GroupBy("ProductID"), Aggregate.Avg("UnitPrice"))
.From("Order Details")
.Where(Aggregate.Avg("UnitPrice"))
.IsGreaterThan(50);
The SubSonic query above will create a SQL statement with a "HAVING AVG(UnitPrice) > 50"
Are you using SubSonic 3.0.0.3 or 2.2?
If you're using 2.2, then I don't think you can do it. I'm unsure about 3.0.
Related
Could anyone help please.
I need to know How to impelement the update #Query with IN operator while using spring data cassandra?
Because I want to use something like this:
#Query("UPDATE objects SET children = ?0 WHERE id IN (?...)")
Ofc if it's possible. Might be I should use native data stax template for this kind of query.
Thx in advance
I am not sure how to implement it, but it is not recommended to use IN in queries with Cassandra ( see this blog for example). It will actually be slower than iterating through the ids and and calling update separately for every id using the standard query, e.g.
#Query("UPDATE objects SET children = ?0 WHERE id = ?1")
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!
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
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.
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.