Count method of file type BYTE

0

It turns out that I have a problem. I can not do the Count method in a Linq query.

It's about counting a data defined as BYTE in the database and I can not show it in the view, it returns 0 , null or all values, but not for example the true " ni false , it returns me all or nothing, it does not do the summation, for example that says "they are 16 true and 8 false"

I want to return it in my view with:

Vista

var item in model @Html.DisplayFor(modelItem => item.rme_vigente (este es el dato byte)) 

It turns out that the Linq query I have is the following and I think it must be wrong, if you return the data of the bbdd.

Driver

public ActionResult Contaorcin() { 
    var Model = db.View_1.OrderByDescending(model => model.rme_vigente); 
    int count = Model.Count(); 
    return View(Model.ToList()); 
} 

Also, I think I should have done a method int i = 0;

    
asked by KonnAN 09.10.2018 в 16:16
source

1 answer

0

The byte transforms it into a boolean object.
you use entity framework? If so, just put the following in the conditional

//suponemos que esta es tu referencia a tu tabla  
var tabla = dbo.Clientes.ToList();         
//suponemos que la variable se llama valido      
int resVerdaderos = tabla.Where(x=> x.valido).ToList().Count();  
int resFalsos = tabla.Where(x=> !x.valido).ToList().Count();

Greetings!

    
answered by 09.10.2018 в 16:23