草庐IT

CURRENT_TIMESTAMP

全部标签

c# - 异步任务中的 HttpContext.Current null

我有一个使用存储库的方法(userRepo):publicoverrideTaskCreateLocalUserAsync(IUseruser,stringpassword,CancellationTokencancellationToken){vartask=newTask(()=>{TUserEntitynewUser=newTUserEntity{Id=user.Id,UserName=user.UserName,Password=password};userRepo.Save(newUser).Flush();returnnewIdentityResult(true);},ca

c# - HttpContext.Current.Cache 是线程安全的吗?

请检查下面的代码:objDDLTable=HttpContext.Current.Cache["TestSet"]asHashtable;if(objDDLTable==null){objDDLTable=newHashtable();arrDDLItems=GetDropDownList("testDropDown");objDDLTable.Add("testDropDown",arrDDLItems);HttpContext.Current.Cache["TestSet"]=objDDLTable;}elseif(objDDLTable!=null&&!objDDLTable.C

c# - 使用最小起订量模拟 HttpContext.Current.Server.MapPath?

我正在对我的家庭Controller进行单元测试。在我添加保存图像的新功能之前,此测试运行良好。导致问题的方法如下所示。publicstaticvoidSaveStarCarCAPImage(intcapID){byte[]capBinary=Motorpoint2011Data.RetrieveCapImageData(capID);if(capBinary!=null){MemoryStreamioStream=newMemoryStream();ioStream=newMemoryStream(capBinary);//savethememorystreamasanimage//

c# - 如何在 Azure 表存储中使用 RowKey 或 Timestamp 检索最新记录

棘手的部分是RowKey是string,它的值类似于MonNov1412:26:422016我尝试使用Timestamp进行查询varlowerlimit=DateTime.UtcNow;//itsshouldbenearertotabletimestampdata.TableQueryquery2=newTableQuery().Where(TableQuery.GenerateFilterConditionForDate("Timestamp",QueryComparisons.GreaterThanOrEqual,lowerlimit));vartest=table.Execut

c# - LinqToSQL 错误 : Operation is not valid due to the current state of the object

在更新命令期间,我收到以下错误:Operationisnotvalidduetothecurrentstateoftheobject我试图从更新命令中删除一列并且它工作正常。此列是一个FK,与其他工作正常的FK相似。这是执行更新的代码:ti.NumeroTitolo=titolo.Numero;ti.RKTipoTitoloGenereTitolo=titolo.RkTipoTitoloGenereTitolo;ti.RKBanca=titolo.RkBanca;ti.DataScadenza=titolo.DataScadenza;ti.RKTipoEsito=titolo.RkTi

c# - 扩展 ASP.NET 身份角色 : IdentityRole is not part of the model for the current context

我正在尝试在我的MVC5应用程序中使用新的ASP.NETIdentity,特别是我正在尝试将ASP.NETIdentity集成到现有数据库中。我已经阅读了有关DBFirst和ASP.NETIdentity的SO问题/答案,并且遵循了所有建议我仍然无法向我的数据库添加角色,尽管我在添加用户时没有问题。这是我的代码:varcontext=newPayrollDBEntities();varroleManager=newRoleManager(newRoleStore(context));boolroleExists=roleManager.RoleExists(roleDto.Name);

c# - 了解 TaskScheduler.Current 的行为

这是一个简单的WinForms应用程序:usingSystem;usingSystem.Diagnostics;usingSystem.Threading;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespaceWindowsFormsApplication{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privateasyncvoidbutton1_Click(objectsender,EventArgse){varts=Task

c# - 错误绑定(bind) Gridview : "The current TransactionScope is already complete"

我正在对从Gridview发送的事件进行级联删除。删除在事务中。这是简化的代码:protectedvoidbtnDeleteUser_Click(objectsender,EventArgse){DataContextdb;db=newDataContext();using(TransactionScopets=newTransactionScope()){try{//deletesomedatadb.SubmitChanges();ts.Complete();}catch(Exceptionex){//handleerror}finally{db.Dispose();BindGrid

c# - HttpContext.Current.Session 为空

我有一个网站,在类库中有一个自定义缓存对象。所有项目都运行.NET3.5。我想将此类转换为使用session状态而不是缓存,以便在我的应用程序回收时在状态服务器中保留状态。但是,当我访问我的Global.asax文件中的方法时,此代码会引发“HttpContext.Current.Session为空”的异常。我这样称呼类:Customercustomer=CustomerCache.Instance.GetCustomer(authTicket.UserData);为什么对象总是空的?publicclassCustomerCache:System.Web.SessionState.IR

c# - 什么时候应该以 TaskScheduler.Current 作为参数调用 Task.ContinueWith?

我们正在使用thiscodesnippet从StackOverflow生成一个任务,该任务在任务集合中的第一个任务成功完成后立即完成。由于其执行的非线性特性,async/await并不是真正可行的,因此此代码改用ContinueWith()。不过,它没有指定TaskScheduler,它是numberofsources已经提到可能是危险的,因为它使用TaskScheduler.Current而大多数开发人员通常期望来自延续的TaskScheduler.Default行为。普遍的看法似乎是您应该始终将显式的TaskScheduler传递给ContinueWith。但是,我还没有看到关于何