Witam, napotkałem się dzisiaj z problemem dotyczącym zapytań Linq. W bazie danych zawieram dane o użytkownikach, które pobierane są w następujący sposób:
using AppCore;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using WoodStoreApp.AppCore;
namespace Magazynier.Data
{
public class UserModel
{
public string User { get; set; }
public string Login { get; set; }
public string Password { get; set; }
public string Privileges { get; set; }
public int WorkerID { get; set; }
public static List<UserModel> GetUsers = SqlOperations.GetData("conf.t_users").Tables[0].AsEnumerable().Select(x => new UserModel()
{
User = x.Field<string>("User"),
Login = x.Field<string>("Login"),
Password = Crypto.GetString(x.Field<string>("Password")),
Privileges = x.Field<string>("Privileges"),
WorkerID = x.Field<int>("WorkerID")
}).ToList();
public static void SaveUser(UserModel model)
{
SqlOperations.Exec("conf.p_users", new SqlParameter[]
{
new SqlParameter("@User", model.User),
new SqlParameter("@Login", model.Login),
new SqlParameter("@Password", Crypto.GetHash(model.Password)),
new SqlParameter("@Privileges", model.Privileges),
new SqlParameter("@WorkerID", model.WorkerID)
});
}
}
}
Sprawdzałem ustawiając breakpointa czy dane faktycznie są pobierane - dane pobierają się. W aplikacji pobieram dane logowania z widoku i chcę pobrać z bazy użytkownika spełniającego kryteria:
var user = UserModel.GetUsers.Where(x => x.Login == model.Login);
Po wykonaniu tego zapytania zmienna ```user nie zawiera danych