我正在创建一种方法,将最后一个事务插入 litedb。
我确实有一个日期字符串,已保存。
这是课程:
public class TransactionPair : TransactionTwo
{
private string returnT;
public TransactionPair() { /* making an empty declaration so we don't NEED to pass it anything if we don't want. */}
public TransactionPair(string returnT, string request)
{
this.returnT = returnT;
JObject o = JObject.Parse(returnT);
AuthCode = o.GetValue("AuthoCode").ToString();
TransType = o.GetValue("TransType").ToString();
AmountString = o.GetValue("AmountString").ToString();
CardType = o.GetValue("CardType").ToString();
Last4 = o.GetValue("Last4").ToString();
RefID = o.GetValue("RefID").ToString();
CardToken = o.GetValue("CardToken").ToString();
ExpDate = o.GetValue("ExpDate").ToString();
DateString = DateTime.Now.ToString("d-MMM-yyyy:HH:mm:ss.f", DateTimeFormatInfo.InvariantInfo);
Request = request;
}
public string Request { get; set; }
}
这是事务对的插入方法。
public void InsertTransactionPair(string json, string request)
{
JObject transObj = JObject.Parse(json);
using (var db = new LiteDatabase(connectionString))
{
var collection = db.GetCollection<TransactionPair>("TransactionPair");
var transactionTwo = new TransactionPair
{
AuthCode = GetValue(transObj, "AuthCode"),
TransType = GetValue(transObj, "TransType"),
AmountString = GetValue(transObj, "AmountString"),
CardType = GetValue(transObj, "CardType"),
Last4 = GetValue(transObj, "Last4"),
RefID = GetValue(transObj, "RefID"),
CardToken = GetValue(transObj, "CardToken"),
DateString = DateTime.Now.ToString("d-MMM-yyyy:HH:mm:ss.f", DateTimeFormatInfo.InvariantInfo),
Request = request
};
collection.Insert(transactionTwo);
collection.EnsureIndex(x => x.RefID);
}
}
我需要一个查找最新条目的 Linq 方法,或者它就像一个队列,我可以在其中弹出返回查询中的第一个值并获取最新的值?