Tag: linq

存储更新LINQ查询并传递给json

我正在尝试创建更新linq查询并使用jQuery生成表,因此在更新后如何保存对表中数据的更改? JQUERY 现在我从表中获取ServiceID,并尝试在ServiceID的基础上更新记录 我试试这个 $(function () { $(‘#services_schdulue’).on(‘click’, ‘tr’, function () { debugger; var row = $(this); var ServiceID = row.find(‘td’)[0].firstChild.data; var s = {}; s.ServiceID = ServiceID; $(‘[ID*=btn_update]’).on(‘click’, function () { debugger; var ServiceID = s.ServiceID; var frequency = $(‘#txt_repeat’).val(); var Freq_Du = $(‘#dura_values’).val(); var Freq_Mil= $(‘#text_mil’).val(); debugger; var obj = {}; obj.ServiceID = […]

如何过滤枚举并在下拉列表中使用它

我是MVC 5新手,我的目标是过滤我的enum中的列表,我将在下拉列表中显示 public enum DayofWeekType { Monday=1, Tuesday= 2, Wednesday=3, Thursday=4, Friday= 5, Saturday=6, Sunday= 7 } 我只想在周五,星期六和星期日显示下拉当登录用户不是管理员时,我无法在Model找到过滤enum字段的解决方案,尝试在模型中添加条件但总是总结出错误。 尝试搜索LINQ和jQuery解决方案。

动态返回类型不起作用但jsonresult返回类型工作

我遇到了一个我不知道如何解决的问题。 我有一个简单的控制器,其返回类型是动态但不起作用。 public dynamic GetPosts() { var ret = (from post in db.Posts.ToList() orderby post.PostedDate descending select new { Message = post.Message, PostedBy = post.PostedBy, PostedByName = post.ApplicationUser.UserName, PostedByAvatar = _GenerateAvatarUrlForUser(post.PostedBy), PostedDate = post.PostedDate, PostId = post.PostId, }).AsEnumerable(); return ret; } 如果我将此动态返回类型更改为JsonResult并替换return ret以返回Json(ret,JsonRequestBehavior.AllowGet); 它会工作。 在我使用web api控制器之前它运行良好的动态返回类型,但不知何故,我面临一些问题,所以我决定使用普通控制器。 我有一个淘汰视图模型,其工作是动态地将post和评论附加到视图页面上。这样的事情— function viewModel() { var self = this; self.posts […]

具有深度的递归层次连接

我在C#和LINQ post中遵循这个Recursive Hierarchical Joins来实现递归连接扩展,以在我的应用程序中显示树视图数据。 由于我有15000个树节点,客户端准备的jQuery DynaTree在错误的浏览器IE 7和8中花费了大量时间(50秒) 为了避免这种情况,我决定最初只加载一个级别,然后按需加载其他子级(延迟加载)。 但是在递归连接中我无法看到设置深度的效果。 即使我指定,它也准备好所有节点。 public static List GenerateTreeByDepth(List nodeList, int deepLevel) { StringBuilder hirTree = new StringBuilder(); List tree = new List(); IEnumerable nodes = nodeList.RecursiveJoin (element => element.DataPointSK,element => element.DataPointSKParent, (NodeDTO element, int index, int depth,IEnumerable childNodes) => new DynaTreeNode() { title = element.DataPoint, key = element.DataPointSK.ToString(), children […]

linqjs group with a sum

这似乎是一个简单的问题,但我正在努力使用linqjs语法。 给出以下基本JSON: { “DateEvent”: “2013-04-23 14:00:00Z”, “DateRecord”: “2013-04-23 14:00:00Z”, “Amount”: -9500, “Type”: { “Description”: “Capital” }, “Currency”: { “ID”: “USD”, } } 使用linqjs如何返回每种货币的总额? Enumerable.From(data) .GroupBy(“{ currency: $.Currency.ID }”, null, function (key, g) { var result = { currency: key.currency, total: g.Sum($.Amount) }}); 上面的代码不起作用。