Accepting Multiple Parameters In MVC 4 Web API Controller And Mapping To Custom Methods?
Jun 25, 2012
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.
In my MVC Web App I am running an ActionResult with the following signature: Public Function Create(ByVal article As Article_Ad) As ActionResult And in my ASPX page I have declared the following form which fields correspond to the model, which is strongly typed:
I am using Fluent NHibernate to map an Oracle database. It is a legacy database so I cant really change everything I want.There is a GUID field, but the keys are still composite (I will change this as soon as I can so that the keys are not composite, but I cant do it right now). The GUID is a VARCHAR2 field with this layout: 551608b1-275d-49f6-9561-44d01aacf23f. The GUID is not added by a sequence in Oracle, but inserted from code (C# or VB.net)[code]Is the problem that I dont use a sequence to generate my GUID? How can I overcome this?
Im currently diving into jquery autocomplete for the first time. To start off with, I had a .net handler calling out to a mssql db and pulling last names. That worked great.However when I try to add additional values it simply doesnt work. The code being used in the handler is as follows.
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim prefixText As String = context.Request.QueryString("term") Dim conn As SqlConnection = New SqlConnection
[code]....
I didnt include the IsReusable when posting, but that is there. why it doesnt like multiple values but will display one lone value?
** Edit ** I just looked in Firebug and it is getting a response but just not displaying it. My implementation of this is pretty simple so far, nothing to fancy.
I am a C# programmer but I have to work with some VB.Net code and I came across a situation where I have two methods on an interface with the same name but different method parameters. When I attempt to implement this interface in a class, VB.Net requires explicitly declaring "Implements MethodName" after the method signature. Since both method names are identical, this is confusing the compiler. Is there a way to get around this sort of problem? I suspect this must be a common occurrence. Any thoughts?
N.B. This was more a case of the programmer not verifying that the interface in question had not changed from underneath him.
I have a table with several rows of data that I need to return to the controller. In my view, I initially load the table by selection of a time period and clicking a button. The table loads all my relevant records but one of my table cells contains a dropdown list. So I should be able make a selection in the dropdown click "update" and my controller saves the changes.
So everything works until I try and save. The model that is sent to the controller is completely null. The list property I have tied to the table cells returns to the controller null.
[Code]...
NOTE: This is written in VB.NET but C# help is welcome. I am familiar with both languages in MVC.
I have a List(Of AddlInfo) with AddlInfo being an object. I'm trying to pass addlInfoList by reference into a function of another class:
[Code]...
This works if I'm not passing the reference into another class, but when I try to do this, I get the following error: Overload resolution failed because no accessible 'Sort' can be called with these arguments:
I wanted to have multiple color for text in single label controller
e.g.
label1.Text = " $ 480.00 "
What I want is character $ in Red color and other digits or character after $ in color blue. $ 480.00 I cannot use separate labels for digits and $ due to limitation
Is it possible to iterate through the properties and methods of a custom class, getting the details about those properties and methods in the process.[code]....
This is more of a user-proofing and aesthetics questions,Whenever we call a method in the .NET framework that requires parameters (most of them), as we're typing the parameters we wish to pass, Intellisense not only tells us the parameter type we need to enter, but it also gives us a brief description of what the parameter is.
Is there any way that we can include that same functionality in the methods that we write?
I am calling a XML web service (standard web service project based on .NET 3.5) and trying to pass custom types as parameters. The custom types are defined in my consuming code and the web service references an assembly from the consuming code to get access to the types. The serialization is being handled by .NET.
<WebMethod()> _ Public Function MyMethod() As MyType Dim myValue as new MyType return myValue End Function
In my consuming code I created a web reference to the service and the proxy classes were created. I gave the service the namespace "WebService". Next I try to make a call to the service and assign the result from the call to a variable, something like this:
Dim service As New WebService.ServiceNameSoapClient Dim response As New MyType response = service.MyMethod()
I get an error from the IDE saying that it cannot convert type mynamespace.WebService.MyType to mynamespace.Entities.MyType. It appears to me that although the types are similar they are being treated as different because of the different namespaces, which makes sense of course.
Edit: So from what I am reading I believe this is by design, that is the proxy types are simply different types and cannot be directly associated with the types in the consuming code.
Today, I'm proceeding with my college work, and am having a little trouble. I'm writing a function, but would like to pass custom types through as parameters, for example Function Game(Section as Game_Section) code here End Function I tried using a structure, but it kept giving me errors
I'm trying to create a program that will read in a custom file similar to a config/INI file and parse the data and store them into variables of a custom class. Essentially I want to be able to read in line by line, split the line by the space and then store the value into a class object's variable with the same name.
For example, I have a class called body. Public Class body Dim height As Double Dim weight As Double End Class
I've used mutiple threads in a VB.NET program but I don't know if I did it right.I would like to start about 3 threads.Can they all use the same methods?Will a separate instance of each method automatically be created for each thread?If not, how do you make sure that the data within the method that is used by one thread is not used by another thread?I would like some data to be shared by all threads.How is data shared among threads?What is the protocol for changing the data and checking for changed data?Is there a good tutorial / website that explains how to handle methods and data when using multiple threads?
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 would need samples/hints on how to progammatically generate executable files after taking custom parameters from the user.I have looked into codedom and I almost got it to work except for the little fact that my application launches the console too and it's meant to be a simple windows form.
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()