How do I get Linq to ignore any parameters that are empty? So Lastname, Firstname, etc? If I have data in all parameters it works fine...
refinedresult = From x In theresult _ Where x.<thelastname>.Value.TestPhoneElement(LastName) And _ x.<thefirstname>.Value.TestPhoneElement(FirstName) And _ x.<id>.Value.TestPhoneElement(Id) And _
GOAL: Bind nested ListViews to LINQ generated iQueryable of anonymous type. I want to use LINQ because you can use GroupBy and bind the nested ListView to the 'it' keyword.
SETUP: I have groups of sets of conditions. Each set of conditions is stored in the BillingCodes table. Each group of BillingCodes is stored in the BillingGroups table.
I have a custom object that stores the ID, Name, and NumCodes for each BillingGroup that the user has chosen.I have a collection of these objects called GroupsList that has a list of the groups that the user has chosen.
Problem 1: I can iterate through GroupsList and grab all the IDs. How do I translate the SQL 'WHERE ID IN(a string of comma delineated IDs)' for LINQ to SQL? Is that the best way to do that?
Problem 2: Once I have the list of BillingGroups I need to iterate through each group. For each group, I need to iterate through the BillingCodes. For each BillingCode I need to generate a WHERE clause that has all of the conditions in the BillingCode. I propose something like so:
for each BillingGroup in BillingGroups for each BillingCode in BillingGroup.BillingCodes where1 = "..." next next
Problem 3: Here's the part where I don't have a clue. I need to dynamically create a query in LINQ to SQL. Keep in mind that I don't know how many groups there'll be or how many codes are in each group.
I'm trying to create a new thread and send multiple parameters as well as a delegate to report back. In VB8 I always hate to do this because it requires either introducing a new class/structure or a delegate. Is there any better way to do this in VB9? I'm looking for a solution something like this :
After searching thru BOL and various forums, I've been unable to determine how to use a backgroundworker component with a procedure that contains multiple parameters. If I understand correctly, DoWorkEventArgs is used to pass parameters. However, all the examples I have found use only one. Since DoWorkEventArgs ends in an "s", I imagine it is possible to use more than one parameter.
I have a connection to a MS SQL database, which I understand is capable of handling multiple SQL statements in one Execution, ie
Code: Using cmdExe As New System.Data.SqlClient.SqlCommand sSQL = "Delete * from mytable where UniqueID=123;Insert into mytable (UniqueID, Field) values (123, 'something')" cmdExe.CommandText = strSingleSQLLine cmdExe.ExecuteNonQuery() End Using
will delete from "mytable" and insert a new record all at once. This is great, but I want to expand upon that to use parameters because using string concatenation in my SQL queries is a bad idea. Now my question is this. If I add a parameter which is used in multiple SQL statements, do I have to add the parameter VALUE twice to the command object? ie, will the following code work?
Code: Using cmdExe As New System.Data.SqlClient.SqlCommand sSQL = "Delete * from mytable where UniqueID=@uniqueID;Insert into mytable (UniqueID, Field) values (@uniqueID, 'something')" cmdExe.Parameters.AddWithValue("@uniqueID", 123)
[code]....
There are two questions here actually...can I add the parameters before setting the command text, and do I have to add the same parameter over and over again?
I'm looking to pass two or more parameters to a thread in VB 2008.
The following method (modified) works fine without parameters, and my status bar gets updated very cool-y. But I can't seem to make it work with one, two or more parameters.
This is the pseudo code of what I'm thinking should happen when the button is pressed:
Private Sub Btn_Click() Dim evaluator As New Thread(AddressOf Me.testthread(goodList, 1)) evaluator.Start()
I need to pass four parameters to a SQL statement and i'm using the following code. It works fine for the first parameter but ignores the rest without erroring.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conz As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
I want to add a parameter to my thread call here is the code. I want to call th.Start(True, sender.Text) and Count(ByVal isRunning As Boolean) will then become Private Sub Count(ByVal isRunning As Boolean, Byval strID As String), but I can't do that. So how can I make this thread accept 2 parameters?
Private Sub btnStart1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart1.Click th = New System.Threading.Thread(AddressOf Count) th.Name = "Button1" th.Start(True) [Code] .....
I have a little challenge. I have a report that I declared a parameter called Department that has default values like this: [Code] The problem is that when I test this (with CR10 or on web), and I select multiple values, the thing does not show the values for the multiple values. It only works when I select a single department. What should I do?
I am writing a socket client into my application. I have multiple socket connections to make to different servers. ClientSocket(1).BeginConnect(endpoint1, AddressOf Connected, Nothing) ClientSocket(2).BeginConnect(endpoint2, AddressOf Connected, Nothing) Both clients call the connected sub... how do I know which one is which? Private Sub Connected(ByVal ar As IAsyncResult)
I am using this code to pass multiple parameters but it works for only one parameter what should i do please please help me.
If TextBox1.Text = "" Or TextBox2.Text = "" Then MessageBox.Show("Please enter Date!", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information) Exit Sub
How do you pass multiple parameters to a Sub which has to be invoked?Again, I've only been coding for about 3 days so please speak as if your trying to teach a child to tie his shoe.
DoObj(byval this as string, byval two as string, byval three as string) I'm trying to pass multiple parameters through a thread to this sub. I have tried this:
I'm trying to implement a Web API project that exposes some models. However, the way the model is retrieved isn't very RESTful. 1.Instead of having just one ID, it has a combination of 4 different ones to populate the model data by running a stored proc on the server.Dim balance as New BalanceSheet(uid, mid, eid, fid)The snippet above will use uid, mid, eid, fid to retrieve the correct record from the database.
I have a linq union statement that has been giving me some trouble and I can't see where the issue is.The error is....All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.
I know the error means that I am selecting different amounts of elements in one of the linq statements, but I've examined this query extensively and I haven't been able to see that as the issue.
Select Distinct s.* from #ScopeIDs x Join Scopes s on s.ScopeID=x.ScopeID or x.ScopeID is null
in LINQ to SQL? (This query would return all Scopes whose ScopeID is present in #ScopeIDs, unless one of the entries in #ScopeIDs is null, in which case it returns all Scopes).
A "literal" translation doesn't work, since LINQ doesn't support joining with multiple conditions - code along these lines ...
From x in ScopeIDs Join s in Scopes on s.ScopeID equals x.ScopeID or x.ScopeID equals nothing Distinct Select s ... doesn't compile.
I have a list of attachments that I need to group by clientCLID and EmailAddress. From this grouped list I only need a list of clientCLIDs. After fiddling for a while I've managed to get it to work as follows:
I spent a lot of time on this problem. I am able to do simple Group By LINQ queries (on one property) but for multiple fields I'm a little stuck... Here is a LINQPad sample of what I want to do :
dim lFinal={new with {.Year=2010, .Month=6, .Value1=0, .Value2=0}, new with {.Year=2010, .Month=6, .Value1=2, .Value2=1}, new with {.Year=2010, .Month=7, .Value1=3, .Value2=4},
in my prev question i was suggested with LINQ solution. It was great and simple. I tried to solve next similar but a bit diff problem with similar approach but i failed.
how can i make the below code better
For Each Item As ListViewItem In RoomsListView.Items For Each Item1 As Room In myBookedRooms If Item1.UIN = Item.SubItems(1).Text Then
it is possible to do a multiple records editing by linqtosql method in one click event?What I've been trying to do is to edit all the names in the table which are having the same account number.
Private Sub Button2_Click(------------) Handles Button2.Click Dim accnt As String accnt = Textbox1.Text Dim db As New memrecDataContext()
[code]....
Why is it these codes could only edit records in one datarow?Can you debug the codes to edit all records which are having the same account number after it is being query?
I'm using Entity Framework code first and pulling some data back from our database. In the table I'm accessing is 13 columns that store the number of a items a customer purchased per week for the last 13 weeks as a char field. I have no control over how this data is stored. I need to total the 13 weeks results together to get a combined total, so take week1 + week2 + week3.... = Total Items Purchased over 13 weeks.In SQL I'd just Cast the char to an Integer and add the values together. But I'm struggling finding a solution to do this in linq.
I tried (From c in Table Select New With {.Usage = (Convert.ToInt32(c.week1) +
I call upon the VB ninjas out there. Here's my situation. I need to eventually be able to pass multiple models to a view. Currently I have a linq to sql class that, of course, has a bunch of generated model definitions. I need to make a model that implements multiple models. I somewhat understand how to do this in C#, but this project is testing my VB skillz. Here's some snippets from my linq to sql models. I need to combine these two into one model to pass to the view.
On my view there is a datatable holding a collection of ServerRow and 4 textboxes (Hostname, OS, Location, Zone). When the user types into any of the 4 boxes I want to immediately filter this list. I have this code setup and ready to go that on the set method of each textbox property I call the filter method.
Now onto the problem: if I have 4 criteria that means I have 2 to the power of 4 different scenarios. What I would like to do is write a linq statement with all of these scenarios dealt with such that if any of the properties are NullOrEmpty they will not be used in the Where clause and on the flip side if there is a value the corresponding field will be searched with a Contains.
I have the following example datatable:[code]And now the user should be able to compare multiple periods. In this example the user chose two periods: 1.1.2010 - 31.12.2010 and 1.1.2011 - 31.12.2011. The result of the example should be:[code]
I have been searching for quite a while about joining multiple datatables via LINQ to dataset (When i say multiple, i don't mean just 2!!!), and it seems there aren't lot of examples in the net. I have seen examples of joining two datatables, done that, no problem there. Now i want to join three datatables. And there's nothing i can find out there.For example i have a 3 datatables: