Solved

update linq mapping?

Posted on 2013-01-03
5
384 Views
Last Modified: 2013-01-10
I made a change to a stored proc, and now this code is complaining:

Procedure or function 'AgentFormList_Get' expects parameter '@ClientID', which was not supplied.

The error is valid, there are a few more parameters to supply after I updated the stored proc.  Do I edit this DataContext form code manually?  It looks like it was computer generated.

		[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.AgentFormList_Get")]
		public ISingleResult<AgentFormList_GetResult> AgentFormList_Get([global::System.Data.Linq.Mapping.ParameterAttribute(Name="AssetID", DbType="Int")] System.Nullable<int> assetID, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="AssetSID", DbType="Int")] System.Nullable<int> assetSID)
		{
			IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), assetID, assetSID);
			return ((ISingleResult<AgentFormList_GetResult>)(result.ReturnValue));
		}
		

Open in new window



I've not done much with LINQ.

How do I get everything updated so that LINQ uses the updated stored procedure, etc?
0
Comment
Question by:Tom Knowlton
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:armchang
ID: 38741707
From what I've known, this procedure was done through SQLMetal. It's  a command-line tool called SQLMetal that generates entity classes, properties, and associations automatically.

You can use that tool to regenerate the stored procedure you've made some update by running the SQLMetal tool on the database.

To get you started, you can run this on the SQLMetal tool: (By the way, I found my SQLMetal.exe file in this location: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools)

sqlmetal /server:pc-ferracchiati /DATABASE:People /user:sa
         /password:sapass /sprocs /code:People.cs

Open in new window

Change the server, database, username & password accordingly.

To give you an idea on how to use the SQLMetal tool, follow this: SQLMetal tool guide

Tell me how it goes.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38741730
I have the same directory path:

C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools

How can I know for sure if the file was generated using SQLMetal or some other way?
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38741733
Is there a way to do this through the Visual Studio IDE (the GUI environement) instead of via the command line?
0
 
LVL 7

Accepted Solution

by:
armchang earned 500 total points
ID: 38742078
How can I know for sure if the file was generated using SQLMetal or some other way?
You will know if it was when you'll try to compare the generated results of the file based on the parameter /code:"filename.cs" to the one you have.

Is there a way to do this through the Visual Studio IDE (the GUI environement) instead of via the command line?
Yes there is. First of all, create a batch file to execute the SQLMetal command passing in server, database, user, password parameters required for the program. Second, there is a step by step process that you can add into your Visual Studio IDE to automate the task:

http://stackoverflow.com/questions/5605885/visual-studio-2010-how-to-run-a-bat-from-inside-the-ide

A
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38742140
Thank you for this information.

I managed to get a hold of one of the other developers and asked him their process for updating LINQ / datacontext etc.

Here are the steps he gave me:

1)  Double-click on the .dbml file
2)  When it opens, delete the existing data class.
3)  Open the Server Explorer
4)  Find the modified Stored Proc
5)  Drag it over to the list of data classes

This will update everthing so that if there are more (or fewer) params expected this will get updated everywhere.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with consolidating excel files using VB.net 2 35
Tracing a live website down to the files which support it 2 30
Code enhancement 4 32
Regarding swagger API 1 32
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question