ADO.NET :: Select Query To Get Records Within Last 24 Hours In Nhibernate?
Oct 20, 2010How to Retrive records within last 24 hrs using Nhibernate.I want to retrieve the 10 records within last 24 hours.
How can i achieve this using Nhibernate.
How to Retrive records within last 24 hrs using Nhibernate.I want to retrieve the 10 records within last 24 hours.
How can i achieve this using Nhibernate.
I have a SQL Data Source that displays records after going through the Query Builder and select "Test Query" yet when I save it, go back to the design mode and select View in Browser I get nothing but a blank screen.
View 3 RepliesI have an SQL 2005 db with a table named "industry_suppliers."
I've created a query to enable someone to search this table using 3 parameters.
The results need to be grouped by "product_description" (which is essentially a category). When displayed on an .aspx page, for example, the results need to look like this:
Apples
Acme Apple Company
Bradbury Orchards
Oranges
A1 Citrus Company
Belfast Growers, Inc
Bradbury Orchards
Notice how "Bradbury Orchards" is repeated under both categories. This is the result I want, EXCEPT in cases where someone wants to filter the search results by category. Let's say someone wants to search just for apple suppliers. The problem I'm having is that any record that appears under apples will also get listed again under any other categories associated with that record. So, searching for apple suppliers, the results are this:
Apples
Acme Apple Company
Bradbury Orchards
Oranges
Bradbury Orchards
I'm having trouble figuring out how to revise my query to avoid this problem.
[Code]....
In my data table i have a Date Column with of type DateTime.
In my sql select query, I want to return all records where the date is today.
I have a basic CMS which I'm adding to a site to display some downloads organised into groups. I have two tables, one for the groups and one for the downloads. I'm using a repeated to display the groups with another repeater inside to display the children. This works perfectly.
However some of my download groups may not have any downloads related to them and I'd like to handle this by filter the groups so that only those with a relate download record(s) are shown.
I'm trying to do this with the query which populates the top repeater based on some ideas I read but I must be going wrong with the syntax.
Here is what I'm using to try and only select downloads groups which have downloads linked to them by the download group ID.
[Code]....
Can anyone offer any thoughts on how I should construct the query to perform this?
I can get my records from my database between days with this query.
[Code]....
but i need filter data between hours..
i have a table which records visits to a page, what i want to do is get a count of the last 24 hours and group the visits by the hour.
This is my table structure;
ID, ChannelNewsID, AddDate
This is what i did so far however it gives me both past and future records where as i want 24 hours previously starting from when the query was run. Here is what my query looks like;
[Code]....
I have,hours(in varchar),Id in table tbl_x ,i need the sum of hours, monthyear(eg. mar 2010)for the last three months.But with two separate queries i am getting these results.but actually i need in the following format
Month/Year TotalHours
----------------- ----------------
Mar 2010 0400
Apr 2010 0450
to get month/Year i am using this query
[Code]....
i have a table with the following columns; [Id] [CreatedDate] [Title] [Description] the data type for the column [CreatedDate] is Datetime. What i want to achieve is, i want a query that can retrieve records in that were created in the past 24 hours.
View 5 Repliesmy requirement is that SSRS 2005 report should show all records with checkboxes(or can be by any other means of flagging ?) .
Now the records for which checkboxes are checked or flagged are only to be included in the exported excel sheet or pdf .
I am excuting SQL Query using Nhibernate, here is my code
public ArrayList getDocumentsForApproval(string ReleaseId)
{
string query = string.Format("SELECT distinct doc.Id, doc.Name as Doc, doc.url as url, suser.Name as Author, ds.name, CONVERT(VARCHAR(11), doc.DateEntered, 101) as DateEntered FROM dbo.Documents doc INNER JOIN DevelopmentSteps ds ON doc.TypeId = ds.Id INNER JOIN DocumentTrackingItems dti ON doc.Id = dti.DocumentId INNER JOIN TrackingItems ti ON dti.ItemStepId = ti.Id INNER JOIN dbo.Releases rl ON ti.ReleaseId = rl.BugTrackerName left outer join (select * from users) as suser on doc.AuthorUserid = suser.Id WHERE doc.DateEntered IS NOT NULL AND doc.DateApproved IS NULL AND rl.ID = '{0}'", ReleaseId);
ISession session = NHibernateHelper.GetCurrentSession();
ArrayList document =(ArrayList) session.CreateSQLQuery(query).List();
return document;
}
Exception Details:
NHibernate.QueryException: Return types of SQL query were not specified [SELECT distinct doc.Id, doc.Name as Doc, doc.url as url, suser.Name as Author, ds.name, CONVERT(VARCHAR(11), doc.DateEntered, 101)
Last night I started working on an NHibernate provider. I'm creating a criteria that several records will match, however I only want to return the most recent record (the record with the largest Id). I thought UniqueResult() would do this it cannot be used if a list would be returned otherwise.
I could theoretically select the full list and then return the desired record, but I believe there is a better way.
I am facing a big problem with simple linq query.. I am using EF 4.0..
I am trying to take all the records from a table using a linq query:
var result = context.tablename.select(x=>x);
This results in less rows than the normal sql query which is select * from tablename;
This table has more than 5 tables as child objects (foreign key relations: one to one and one to many etc)..
This result variable after executing that linq statement returns records with all child object values without doing a include statement.. I don't know is it a default behavior of EF 4.0 . I tried this statement in linqpad also..but there is no use... But interesting thing is if I do a join on the same table with another one table is working same is sql inner join and count is same..but I don't know why is it acting differently with that table only.. Is it doing inner joins with all child tables before returning the all records of that parent table?
i have two tables named
1.LookupPageInfo and (LookupPageInfoId,pathmessageID,pagemessageID)
2.Messages (MessageId,MessageText,ChannelID)
Now i need to write a query something like this........in the query i need to pass the pathmessageid and needs to get messagetext from Messages Table,i am not sure how i need to write the below query..can someone guide me how can i write a query......as below..
select LookupPageInfoId,
PathMessageID,
pagemessageID,
(select messagetext from Messages where MessageID=PathmessageId) as TEXT from LookupPageInfo
What is difference between select { } and select new {} In Linq Query
View 3 RepliesI am writing a linq query to select a blogpost,
[code]....
The blogpost i am testing got 3 tags attached to it. The table structure is:
(table)BlogPost -> (table)BlogPostTags <- (table)Tags
So the BlogPostTags table only contains 2 fields, BlogPostID and TagID.
When i run the query above i get 3 results back. Same blogpost 3 times but with 1 tag in each. It should return 1 post with 3 tags. The problem lies in the Tags query above.
How can I SELECT second if first SELECT returns nothing?
View 8 RepliesI have a grid view which contains Hours as one of the columns.. now, i need to have a total hours in the footer (sum of hours for all rows).
View 2 RepliesThere is likely an easy solution to this problem, but I'm stalling on it.Problem:Using EntityDatasource with a where="filed_id = @xxxx" the parameter is tied to a dropdownlist and works fine except I want to be able to select all records or basically no where condition. Is there a some way to do this without going to code behind?
View 2 Repliesi am trying to get a list of recors that are not already linked via many to manyTable "keyword" is linked to table "directories" thought a many to many link using table "directoriesKeywords"what i want to do is get a list of keywords that are not linked to a certain directory.I have somthing like this( i ahve tried many variations
[Code]....
I'm trying to select all records from db that SUPPORT_END_DATE greater than Date of the day
like this :
Select * From Supp_table Where SUPPORT_END_DATE > "Date Of the day I get it from textbox.text=Date.ToDay()"
How do i search with stordprocedure instead of selecting from my code behind
protected void btnSingle_Click(object sender, EventArgs e) {
if (txtSingleDate.Text == "") {
ScriptManager.RegisterClientScriptBlock(btnSearch, this.GetType(), "alert", "<script>alert('Enter InvoiceNo ... !!')</script>", false);
} else {
[Code] ....
I am trying to insert about 100,000 in my SQL Server database. It is really slow when I create 100,000 separate queries, so I tried to insert all these records in one query, it worked for the first few thousands records but then it threw me a timeout error.
What would be the fastest way to insert multiple records into database?
I have table in database with xml field and data like below
[Code]....
there are no records found
i have a link query that retrun all the records that have their status = 'completed' ordered by their ids, but i want to return only three records not all the records
View 2 Replies