Wednesday 15 January 2014

c# - Do not return Stored Procedure result as List -


After the

target

do not return the result process stored in the list.

The problem

My stored procedure is working well, but till now I have many results with them. . Now my wish is to bring only one result

Look for your query:

  productName, measure.Abattle form product.Name measureAbattle forms from bm_products to select product bm_measures Form measurement in the form of measure.Id = product.MeasureId where product.Id = productId;   

As you can see, I'm searching for a product with a specified ID. When I run the process, my results are:

preview 1

I have already run the import function and made me this builder ( Builders / Products.cs ) to get the result of the query:

  public Static list & lt; GetSpecificProductToShoppingList_Result & gt; BuildItemToShoppingList (Nullable & lt; Integer & gt; productId) {From the list & lt; GetSpecificProductToShoppingList_Result & gt; Product = DB getSpecificProductToShoppingList (productId). ToList & LT; GetSpecificProductToShoppingList_Result & gt; (); Return product; }   

Yes, this is generating a list because I am asking for creation, but the thing is that I have only one result. I do not need a list of results.

Can I change the builder to work like I want to do?

Description

I am using C # Net + MVC 4+ unit framework 5 + razor engine.

Why -1?

Why did someone become negative in my question

  public static getSpecificProductToShoppingList_Result BuildItemToShoppingList (Nullable & lt; integer & gt; productId)? {GetSpecificProductToShoppingList_Result Product = Database. GetSpecificProductToShoppingList (productId) .FirstOrDefault (); Return product; }   

The first object in the list will return or if there is no such thing.

No comments:

Post a Comment