Linq To Sql Time Filter
Jul 12, 2011I'm trying to filter out the time which is greater than 8:00 am and store it in array . Can anyone give me some suggestion?[code]
View 1 RepliesI'm trying to filter out the time which is greater than 8:00 am and store it in array . Can anyone give me some suggestion?[code]
View 1 Repliesi want to filter date and also time (shortime) for example if Datum.hour="8:15" andalso Datum.day of week "Saturday"or "Monday" now i can only filter date ... this is my filterline objbindingsource.Filter = "Datum > = '" & Dtp1.Value.Date & "'"
View 5 RepliesExample-I have a person class
Public Class Person
Private _fname As String
Public Property Fname() As String
[Code]...
Public Sub adjectAllNormals()
Dim qry As LinkedList(Of CElement) = From elm In Elements
From id In SelectIDs()
Where elm.ID = id
Console.WriteLine(qry.Count)
End Sub
I have a list(of t) and I got a iqueryable(of a)
I want to filter out any item from the iqueryable(of a) where a.id = t.myotherid
I'm not really sure how to write this query[code]...
I am trying to grasp using Linq to read and filter xml files. I've been googling and trying all day long but still not successful.[code]
1. Firstly I want to select a contact with a certain node value, my code looks like this:[code]
2. The third level nodes have some same descedants child elements. Is it possible to sort the entries by <contactId>? How can I do that? For example I want to have a result like this:[code]
Imagind I have the following in VB:
function doSomething()
From ou In ctxt.Users.Where(Function(p) p.UserName = username)
...
end function
how can I send the filter as parameter (something like below)?
function doSomething(filter as whatTypeHereAndHowToInstantiateInCallingFunction)
From ou In ctxt.Users.Where(filter)
...
end function
I am trying to write a query for an existing database, I am using LINQ on EF3.5 inside VS2008 as that is the only environment available to me.I have a starter query that gives me a list of items so the user can select what they want.
"e.Result =
From c In MLDb.TBL_FeatureInfoSet
Order By c.INSP_ROUTINE_NM
Select c.INSP_ROUTINE_NM
Distinct"
The user can then select from the list one or several items they are intersted in and i want to use these as the filter in a further database call. It's not then difficult to have a where to filter on one string however, I would also like to be able to allow the user to select several items from the list box and the data for all of those to be returned.
[Code]...
I`m looking for a way to parse a parameter name like linq does.I want to filter before i download the date from the database.With LINQ the data is already red into a dataset. I only want to select data from the database witch i need. how i can send a property name to a function without using the property name as string and without to use to mutch code inside the function and without creating an instance of the object, etc.
Module
Module1
Dim user
As user =
[code]....
I have a LINQ query:[code]How can I pass "MyField" to the Sub and make the LINQ "Where" clause work?
View 2 RepliesI am wondering if it is possible to filter data from a datatable.Sample datatable
Quote:
Sno CatID Nos
1 XYZ 25
[code].....
I've got a datacontext and created a binding source using LINQ to sql but cannot filter said bindingsource. The supportsfilter of the bindingsource is set to false ? why ? I can't find any info to say that I cannot filter a binding source based on a linq query.[code]
View 3 RepliesOK I have a base query that is returning a list (ObjectQuery, actually but I don't think it matters) I have about 5 subtypes based on the main type and I need to filter them. Everything works fine until I want the results to be of the main type (not a subclass) Basically I have a query that includes everything, then I filter out the types that are not checked in a checkedbox list. (asp.net) Lets say I have an Entity named Task, and SubTask1 and SubTask2 that inherit from Task
[Code]...
Could not find this through Google or in SO questions.I have a checkbox listbox on my form. I want to filter my List by the list of selected Ids from that listbox that are checked, in SQL I would have done this like "Where TypeId In (1, 4, 5, 7)"... how do I do that in LINQ?
I feel like I am missing a really obvious answer, but cannot get it.
For argument sake... here is the what I have for sample data:
In Colors (List<of currentColors>)
ID, Name, TypeId
1, Red, 1
2, Blue, 1
3, Green, 2
4, Pink, 3
Selected Types 2 and 3 in CheckboxList: filteredColors
[Code]...
Basically i have a list(of TransRecord)
vb Public Class TransRecord
Public TableName As String
Public PKs As String
[CODE]...
And want to create a linq filter to select only unique records for TableName + PKs (group by) ... but want it to select only the record with the highest ID for this group by.
i have the following records, the FIELD(Timed) is formatted as datetime in sql
1/1/1900 12:00:00 PM
1/1/1900 12:02:00 PM
1/1/1900 12:05:00 PM
i used this query using my crystal report(XI).
crys_rep.selectionformula = "{vClient.Timed} >= #" & dFrom.text &"# and {vClient.Timed} >= #" & dTo.text &"#"
... other codes is point to my crystal report location and refreshed.
why there is no record found using my visual.net 2008
but when i try to sql query using the following code:
Select Timed from vClient where (Timed >= '12:00:00 PM') and (Timed <= '12:05:00 PM')
there is no problem..
I'm using Vb.Net 2008, SQL 7, Crystal Report XI
dp.SyntaxHighlighter.ClipboardSwf = '/dp.SyntaxHighlighter/Scripts/clipboard.swf'
dp.SyntaxHighlighter.HighlightAll('7c90d506846a47cda9bc951d960bafe6')
dp.SyntaxHighlighter.HighlightAll('1ce19e03a5a54baea62fef35fbb94f92')
im using mssql 2000/i do have a problem on selecting dates like this, [code] because the cdate_time_log has also the time/how can i remove the time in able for me to filter it by date??
View 2 RepliesI'm trying to filter date and time
Dim
startTD As
Date = Dtp1.Value.Date
objbindingsource.Filter =
[code]....
I can finally filter my DataGridView every time a checkbox is checked or unchecked. However, I do not need it to filter out all of the messages each time a row is added, so I just need to check the current message. The following sub's demonstrate how I am doing this.
Public Sub FilterAllMessages()
'Show all rows
For Each showBand As DataGridViewBand In MessagesDataGridView.Rows
If showBand.Visible = False Then showBand.Visible = True
Next
[Code] .....
Great, they both work as intended...but I believe I am losing out on efficiency with the way I have this. I have tried adding another public sub CheckMessage() to run through the row, pretty much doing what each long list of If/ElseIf checks does.
IN the FilterLastMessage() I just call CheckMessage(), and in the FilterAllMessages() I call it like this:
For Each band As DataGridViewBand In MessagesDataGridView.Rows
CheckMessage()
Next
This isn't working as it is unable to get the index for each message when I have it FilterAllMessages(). I'm just wondering about making the 2 sub's above more efficient so I can have it CheckMessage() just once, instead of it doing basically the same thing twice. Also, the messages all go on to a DataGridView, and this will be constantly writing messages to the window. After a while I would imagine that this will bog down the program, so I am wanting to keep the number of messages that are displayed < 2000. How is the most efficient way to achieve this?
I want to change the log file filtering at filtering at runtime. I am referring to the traceEventType in the following example.
My.Application.Log.WriteEntry(String.Format("{0:T} DeserilizeProperties", Now), _
TraceEventType.Verbose)
I have found the documentation that allows me to change it in the config file, but I need to do it at runtime. What I am trying to acheive is to allow a beta tester to turn on more detailed logging (according to the TraceEventType...) when encountering an issue in order to email me the log. And then switch back to less detail.TraceEventType.Information)
.Application.Log.WriteEntry(String.Format("{0:T} Send email", Now), TraceEventType.Information)
I know that LINQ queries are deferred and only executed when the query is enumerated, but I'm having trouble figuring out exactly when that happens.Certainly in a For Each loop, the query would be enumerated.What's the rule of thumb to follow? I don't want to accidentally enumerate over my query twice if it's a huge result.
For example, does System.Linq.Enumerable.First enumerate over the whole query? I ask for performance reasons. I want to pass a LINQ result set to an ASP.NET MVC view, and I also want to pass the First element separately. Enumerating over the results twice would be painful.It would be great to turn on some kind of flag that alerts me each time a LINQ query is enumerated. That way I could catch scenarios when I accidentally enumerate twice.
I'm trying to filter the results of a xml file. One of the fields I've been requested to filter is the attribute price of each node. The problem is the xml is from a spanish source and the prices are with decimal separator being , instead of . and thousands separator is , instead of .I'm trying to get an xml file filtered where only nodes withprices lower than one supplied appear.
The xml structure is:
<RoomStays>
<RoomStay InfoSource="" Price="201,60" Discount="0" MealPlan="Sólo alojamiento" MealPlanId="1" Provider="Marsol" ProviderId="3" HotelName="HOTEL LA ESTACION" Rating="" Latitud="" Longitud="">
[code]....
I've tried to filter using XPath and Linq2Xml. I've come to the conclussion I have to replace , with . and . with , but I get 0 results.With values below 1000 where there is only , I've got it using:
doc.XPathSelectElements(./RoomStays/RoomStay[translate(@Price,',','.')<=256.78])
But when there are prices above 1000 with thousands separator . it doesn't work, so I tried:
doc.XPathSelectElements(./RoomStays/RoomStay[translate(translate(@Price,'.',''),',','.')<=256.78])
But it returns 0 results (I tried to use replace function instead of translate to remove the . characters but I get an exception).
I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.
View 2 RepliesI as seeking to move 10 file every 10 minutes from one folder to another using .NET (vb c#) I am was thinking that i could of achieve this with LINQ query, but i cant get my head around this would there be a solution with LINQ or otherwise that can select the last 10 files form or top 10 files. so that i can move only these files from Directory1 ( the big pool of files) into director 2 ( a smaller more manageable pool of files).If all fails- then i wll manually have to copy or cut to at a time.
View 1 RepliesI need to have a query which list all the user according to the date value in the database. Problems is this, in the database the date format is 5/5/2009 4:30:12 but I want to compare with 5/5/2009. I think the value of the based date is 5/5/2009 12:00:00 and that's why I couldn't query it.
The query is something like
dim db = new databcontext
dim user = from u in db.datacontext where u.signUpTime = 5/5/2009 select u.
I need help on how can I transfer a query from Access to LinQ that calculate the average in time per transaction during a given date.the working Access query is:
Avg(DateDiff("s",CVDate(Format([start_time],"hh:nn:ss")),CVDate(Format([finish_time],"hh:nn:ss")))) AS Expr1, Format([Expr1]3600,"00") & ":" & Format(([Expr1]60) Mod 60,"00") & ":" & Format([Expr1] Mod 60,"00") AS format
How can I port this to LinQ?
I have an untyped dataset returned from my WebService. The user wants to dynamically construct a query referencing tables and columns and specifying values to test for.I have looked at Lambda Expressions and the Expressions.Expression Namespace. I think these provide the answer I'm looking for, but I'm not certain how to go about contructing the linq expressions to extract the datarows I'm looking for.
I plan on limiting the result to one datatable that the query will result in and i"ll provide the joins from the user's constructs.For a simple example I have a DataTable with (n) rows called "Table", and in it there is a computed column called "b_IsActive" that has the expression "Convert(IsActive, 'System.Boolean')". The user wants to retrieve all rows in "Table" where field "b_IsActive" is true.
I have created a Dictionary class (MyDictionary for the example). I am currently trying to pass MyDictionary into a function, filter it into a new instance of MyDictionary and pass this new instance into another method. When I am attempting to create the second instance from the filtered first instance of MyDictionary via Lambda Expressions and the ToDictionary Method, I am getting the following error:
Unable to cast object of type 'System.Collections.Generic.Dictionary`2[System.Int32,System.String]' to type 'MyDictionary'. I have simplified the example and recreated it in LINQPad and am getting the same error.
Here's the simplified version of my code:
[Code]...
I have a table (Projects) which is linked to projectVersions on projectID..projectVersions contains several columns on which I'd like to filter a returned project (and associated projectVersions) list. For example there is a "capacity" column and a "country" column. I am doing a filtered list of projects on one page and I'd like to include all projects where any one of the associated projectVersions has a capacity of 750ml and a country of "France" for example.It may be that a particular parameter is not set and so I pass a zero to indicate not to filter on that.I guess this needs some kind of subquery as when I try and do something like this: [code] it doesn't work as the "xxx" bit, being one-to-many, expects me to specify an item to get at the entities within and yet I want to query where ANY of the associated versions match one of the criteria.
View 1 RepliesI m trying to filter a sql db with many filter criteria which inert the user in textboxes .. i ve tryed this query
[Code]...