这是读取jar文件的正确方法:
rules="./src/main/resources/Rules.json"
如果没有,最好的方法是什么?
答案 0 :(得分:0)
App.class.getClassLoader().getResourceAsStream("Rules.json");
是使用资源文件的更好方法。
答案 1 :(得分:-1)
使用Guava替代ma3stro的答案:
public void Update(UserEntity person)
{
UserEntity user = new UserEntity();
SurveyEntities dbcontext = new SurveyEntities();
var query = (from p in dbcontext.Users
where p.UserId == person.UserId
select new UserEntity() { UserId =p.UserId , FirstName = p.FirstName, LastName = p.LastName, Birth = p.Birth.Value, Password = p.Password, UserName = p.Username, Email = p.Email, Active = p.Active.Value }).SingleOrDefault();
query.FirstName = person.FirstName;
query.LastName = person.LastName;
query.UserName = person.UserName;
query.Password = person.Password;
query.Email = person.Email;
query.Birth = person.Birth;
query.Active = person.Active;
try
{
dbcontext.SaveChanges();
}
catch (Exception e)
{
Console.WriteLine(e);
// Provide for exceptions.
}
}