我正在使用Linq:
using System.Linq;
using Db4objects.Db4o.Linq;
我的数据库如下:
User user1 = new User();
user1.Name = "Bob";
user1.Surname = "Topson";
user1.No = 160456;
user1.Birth = new DateTime (1998, 5, 12);
User user2 = new User();
user2.Name = "Rob";
user2.Surname = "Simpson";
user2.No = 143457;
user2.Birth = new DateTime (1996, 8, 4);
我的user.cs代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace db4o
{
class User
{
public string Name { get; set; }
public string Surname { get; set; }
public int No { get; set; }
public DateTime Birth { get; set; }
}
}
答案 0 :(得分:0)
//第一个问题的答案
var r = from User p in db
// ling for some data from your db
where user1.Birth >= Convert.ToDateTime(1996 / 8 / 4) && user1.Birth <= Convert.ToDateTime(1998 / 8 / 4)
select p;
foreach (User p in r)
{
// Here I use some method
// I'm not a C# programmer
int myint = p.No;
string str1 = Convert.ToString(myint);
str1 = str1.Remove(str1.Length - 1);
str1 = str1 + "0";
p.No =Convert.ToInt32(str1);
// now save data
db.Store(p);
// print data
Console.Write(string.Format("{0} {1}\n", p.Name, p.No));
}