在 linq 表达式中检查 DateTime 是否为空的方法在哪里?我有 IEnumeable 方法,我从数据库中返回数据
return _requestRepository.ExecuteProcReader(
myRequest,
new SqlParameter("@userName", user)).Select(items => new Feed
{
Id = (int)items[0],
Title = items[1].ToString(),
Body = items[2].ToString(),
Link = items[3].ToString(),
PubDate = (DateTime) items[4]
});
Run Code Online (Sandbox Code Playgroud)
items[4] 是一个日期时间,在数据库中可以为空。那么,如何检查类似的东西
if(items[4] is DateTime)
{
PubDate = (DateTime) items[4]
}
Run Code Online (Sandbox Code Playgroud) 我有前任的标签。: <label id="labelId" class="control-label col-lg-4">Some text ()</label>, 我怎样才能在刹车中间插入文字,然后清除它?
我试过了 :
$('#labelId').replace("()", "(new)");
Run Code Online (Sandbox Code Playgroud)
但这对我不起作用
我正在尝试用asp.net mvc制作我的第一个web应用程序,包括带linq的远程数据库.所以我正在使用mvc的默认模板,我在AccountController中重新编写了使用linq实现注册用户的代码,现在我很有意思使用async.那么可以用异步处理linq吗?如果是的话,请告诉我如何做到这一点,这将对我非常有帮助.这是我通过linq注册的例子:
[AllowAnonymous]
public ActionResult Register()
{
return View();
}
//
// POST: /Account/Register
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
using (DataBaseClassDataContext dc = new DataBaseClassDataContext())
{
Users tbUsers = new Users();
tbUsers.Login = model.Login;
tbUsers.Name = model.Name;
tbUsers.Surname = model.Surname;
tbUsers.Password = model.Password;
tbUsers.E_Mail = model.Email;
tbUsers.Knowledge = model.Knowledge;
dc.Users.InsertOnSubmit(tbUsers);
dc.SubmitChanges();
ModelState.Clear();
ViewBag.Message = "Successfully Registration Done";
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
Run Code Online (Sandbox Code Playgroud) 我有3个表:users,feed(id,body,title,link)和userstofeed(id,userid,feedid,isread)而我试图读取userstofeed表布尔值,它带来的IndexOutOfRangeException.请告诉我,我做错了什么
while (reader.Read())
{
rssFeed.Title = reader["title"].ToString();
rssFeed.Body = reader["body"].ToString();
rssFeed.Link = reader["link"].ToString();
rssFeed.IsRead = (bool) reader["isread"]; //IndexOutOfRangeException here
yield return rssFeed;
}
Run Code Online (Sandbox Code Playgroud)
这里是sql store程序:
create proc spGetItemsByUser
@userName nvarchar(50)
as
begin
declare @userId int
declare @feedId table (id int)
select @userId = id
from Users
where name = @userName
insert into @feedid (id)
select feedid, isread
from userstofeed
where userid = @userId
select * from feed where id in (select id …Run Code Online (Sandbox Code Playgroud) 如何从kendo组合框值获得?我总是对它进行定义.我已经使用过这些变体,但它们并不适用于我
var selected = $('#typesCombo').data('kendoComboBox').val();
var selected = $('#typesCombo').data('kendoComboBox').value();
var selected = $('#typesCombo').data('kendoComboBox');
Run Code Online (Sandbox Code Playgroud)
并得到如下错误: Cannot read property 'val' of undefined
这是我的代码:
JS:
$('#loadContainer').load("@Url.Action("Load", "Home")" + id);
var selected = $('#typesCombo').data('kendoComboBox').val();
if (selected == '') {
...
}
Run Code Online (Sandbox Code Playgroud)
HTML:
@(Html.Kendo().ComboBoxFor(x => x.Types.Name).Name("typesCombo")
.DataTextField("Name")
.DataValueField("Id")
.HtmlAttributes(new { style = "width:100%", id = "typesCombo" })
.BindTo(Model.TypesList))
Run Code Online (Sandbox Code Playgroud) c# ×3
javascript ×2
jquery ×2
linq ×2
asp.net ×1
asp.net-mvc ×1
asynchronous ×1
combobox ×1
datetime ×1
html ×1
kendo-ui ×1
sql ×1
sql-server ×1