1

I have a problem with DataGrid in wpf

this is a class :

class Superviser
    {
        public long Id = 0;
        public string name = "";
        public string father = "";
        public string code = "";
    }

and this is a function that build a list of this class object

public List<Superviser> allSuperviser()
        {
            return db.tbPersons.Where(i => i.level == StaticsObject.isSuperviser).Select(x => new Superviser
            {
                Id = x.Id,
                name = x.firstName,
                father = x.father,
                code = x.code,
            }).ToList();
        }

and I use this code to set this list in datagrid

dgvPerson.ItemsSource = classPerson.allSuperviser();

but when run program datagrid is empty !

tip : The list is not empty.

Where is the problem?

How do I display this list on DataGrid?


mongojs driver not connecting to mongodb

i have been trying to connect to my local mongodb using mongojs package but its not connecting at all. i have my mongo service running on http://127.0.0.1:27017/ and below is my code :

    var express = require('express');
var app  = express();
var bodyParser = require('body-parser');
var mongo= require('mongojs');
var db=mongo('catalog',['products']);

app.use(bodyParser.json);
//adding our first route  name 
db.on('connect', function () {
    console.log('database connected')
})
app.get('/',function(req,res){
    res.send('It Worked');
});
app.get('/products',(req,res)=>{
    db.products.find(function (err,docs) {
        if (err) {
            res.json(err)
        }else{
            res.json(docs)
        }
    })
});

i have set event on connect to log if the connection is established but nothing is showing up.do you i could use mongoose or some other packages if it doesnt work at all?

4

1 回答 1

1

你好,阿吉安我解决了

我将课程更改为:

class Superviser
{
    public long Id { get; set; }
    public string name { get; set; }
    public string father { get; set; }
    public string code { get; set; }
    public Superviser() { }

    public Superviser(long Id, string name, string father, string code)
    {
        this.Id = Id;
        this.name = name;
        this.father = father;
        this.code = code;
    }
}

并将功能更改为:

public List<Superviser> allSuperviser()
        {
            return db.tbPersons.Where(i => i.level == StaticsObject.isSuperviser).Select(x => new Superviser { Id = x.Id, name = x.firstName + " " + x.lastName, father = x.father, code = x.code }).ToList();
        }

问题已解决:)

于 2018-06-30T08:07:10.210 回答