Solved

update linq mapping?

Posted on 2013-01-03
5
360 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: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: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: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: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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now