GetItemName", IsComposable = true)]
[return: Parameter(DbType = "VarChar(100)")]
public string GetItemName([Parameter(Name = "itemID",
DbType = "int")] int @itemID)
{
return ((string)(this.ExecuteMethodCall(this,
((MethodInfo)(MethodInfo.GetCurrentMethod())),
@itemID).ReturnValue));
}
If you see the attribute for the method, it is the same one used for the stored
procedure. Only the name is the difference here. The execution is also similar to the
stored procedure. We can call the function as follows:
string itemName = db.GetItemName(1);
Class Generator Tool
In all the previous examples, we have seen different ways of creating database
objects using LINQ to SQL support. This is fine while creating a new database and
its objects, and mapping the same with the entity classes. If we have a database that
already exists for our application to use, we will end up creating corresponding
class objects, which will consume a lot of our time. In order to avoid this, LINQ to
SQL comes with a new tool called SQLMetal, which takes care of creating the entity
class objects for the existing database.
Pages:
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197