select data from a sql server procedure in C #

-1

I made a procedure that takes all the data of all the columns of my sql table of interest, in my application asp in C # I can put all the rows in a list, but I need to refine this search by taking only all the data of a column only. I researched a bit and saw that with Lambda expressions this is possible, but I did not understand how to implement it. Any help?

    
asked by anonymous 11.01.2018 / 12:10

1 answer

0

Assuming Lista<> is Lista<Pessoas> ListaDePessoas() , and you have all people according to return of your Procedure. Following this line of reasoning your Table has the Field (ID, Name, Birth, etc.), Logically, each Person object in your List has a property referring to each Column.

I'm assuming you want to gather all the records in the column that represents each person's Name.

using System.Collections.Generic; // - > responsible for supplying type List<>

Believing that your list is filled with all the desired Tuples: you can store the desired column in another list, an array or direct into a component.

I will use a List<> to store this desired column.

List<string> ListaNomes = new List<string>();

ListaDePessoas.ForEach(delgate (Pessoas pessoa))
   ListaNomes.add(pessoa.Nome);
);

I hope I have helped, even with little information.

    
14.01.2018 / 03:11