我有一个显示派对列表的视图.每一方都有一个ActionLink.
@Html.ActionLink("Edit", "Edit", new { id = 234 })
Run Code Online (Sandbox Code Playgroud)
我的操作链接转到编辑操作并呈现编辑器视图.
主要思想是,在单击ActionLink时,应该出现一个带有编辑器视图的jQuery对话框,并且视图中的任何编辑都应该保存到数据库中.
我的问题是,我不知道如何打开jQuery对话框中的视图.那你怎么在jQuery对话框中打开一个视图呢?
如果不使用ActionLink就可以实现同样的目的,那也很有帮助.
我有以下查询,从多个选择中获取结果.现在我希望这些在临时表中.
有没有办法在不创建表的情况下将这些插入到临时表中?
我知道如何选择
Select * into #s --like that
Run Code Online (Sandbox Code Playgroud)
但是如何做一个以上的选择呢?
SELECT Ori.[GeoBoundaryAssId], Ori.[FromGeoBoundaryId], Ori.Sort
From [GeoBoundaryAss] As Ori where Ori.[FromGeoBoundaryId] = (select distinct [FromGeoBoundaryId] from inserted )
Union
SELECT I.[GeoBoundaryAssId], I.[FromGeoBoundaryId], I.Sort
From [inserted] I ;
Run Code Online (Sandbox Code Playgroud) 我们在Windows 7上使用VS 2012和32位操作系统.
我已从工具 - >选项 - >调试 - >编辑并继续启用"编辑并继续"功能.
我仍然无法在调试模式下编辑.cs文件.
有人可以建议我错过了什么吗?
我在mvc控制器类中保留了断点.当它达到断点时,我尝试编辑并得到以下消息:
Changes are not allowed in the following cases:
-When the debugger has been attached to an already running process
-The code being debugged was optimized at build or run time.
-The assembly being debugged is loaded as domain-neutral.
-The assembly being debugged was loaded through reflection.
-When Intellitrace events and call information is enabled.
Run Code Online (Sandbox Code Playgroud) 我想将linq查询结果转换为datatable,以便我可以将数据表分配给GridView以在asp页面上显示它.
但是我无法将结果转换为datatable,我没有在我的代码中获取CopyToTable()方法.
请告诉我这里做错了什么?
var gradeData = (from data in oAngieCtxt.prc_ShopInstanceCustomersData(Convert.ToInt32(this.ShopInstanceID), 10000, false)
.Where( row => row.RecievedPoints != "n/a" )
.GroupBy(row => new { row.Name })
.Select(g => new GroupedPoints()
{
Name = g.Key.Name,
TotalPoints = g.Sum(x => Convert.ToDouble(x.RecievedPoints) * (x.Weightage.ToString() == "0.00" ? 1 : Convert.ToDouble(x.Weightage)))
})
select data).ToList();
DataTable dt = gradeData --gradeData.CopyToTable()
Run Code Online (Sandbox Code Playgroud)
注意:可以使用对dataextentions dll的引用.
提前致谢
我是初学者使用lambda表达式.
我有一个经销商名单,foreach经销商我必须计算等级.
要求是将等级计算分成单独的方法.
所以我正在编写以下两种方法,但是我无法将参数传递给CalculateGrade()方法,
public IEnumerable<Dealers> GetDealerGrades(IEnumerable<Dealers> gradeData)
{
return gradeData
.GroupBy(row => new { row.Name })
.Select(g => new Dealers
{
Name = g.Key.Name,
TotalPoints = CalculateGrade(x => Convert.ToDouble(x.RecievedPoints),
y => y.MaxPoints,
z => Convert.ToDouble(z.Weightage))
})
.ToList();
}
private double CalculateGrade(double d1, int d2, double d3)
{
return ( d1 / d2 )
* d3 == 0.00 ? 1
: d3;
}
Run Code Online (Sandbox Code Playgroud)
有人可以建议如何传递参数,或者如何传递lamda表达式并计算等级?
提前谢谢了...
我的模型绑定器中有以下方法:
protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
{
if (bindingContext.ValueProvider.GetValue("Id") == null)
{
string s = bindingContext.ValueProvider.GetValue("IsSoftDeleted").AttemptedValue;
bool d = Convert.ToBoolean(s);
return OrgFactory.Create(bindingContext.ValueProvider.GetValue("Caption").AttemptedValue,
bindingContext.ValueProvider.GetValue("NameInUse").AttemptedValue,
bindingContext.ValueProvider.GetValue("Description").AttemptedValue,
d, new Party());
}
else
{
return OrgFactory.Create(bindingContext.ValueProvider.GetValue("Caption").AttemptedValue,
bindingContext.ValueProvider.GetValue("NameInUse").AttemptedValue,
bindingContext.ValueProvider.GetValue("Description").AttemptedValue,
Convert.ToBoolean(bindingContext.ValueProvider.GetValue("IsSoftDeleted").AttemptedValue));
}
}
Run Code Online (Sandbox Code Playgroud)
在create.cshtml视图中,如果我检查chebox的IsSoftDeleted,它在模型绑定器中的值将变为"true,false",它应该只是真的.
你能告诉我做错了什么吗?
create.cshtml
@using PartyBiz.Models.Objects
@model Organization
@using (Html.BeginForm("Create", "Organization", FormMethod.Post))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Create a New Organization</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Caption)
@Html.EditorFor(model => model.Caption, new { @class = "txt"})
@Html.ValidationMessageFor(model => model.Caption)
</div> <br />
<div class="editor-label"> …Run Code Online (Sandbox Code Playgroud) 我之前提出过类似的问题,没有答案.
如何创建可以显示传递给它的列表或单个模型的通用mvc4视图.model可以是Person,Organization或Party,无论传递给它的是什么.
我有以下接受BuildAppStat对象作为参数的方法。
但有时它可能为空。
所以我这样称呼它:
sourceId: bas.BuildAppStatId ?? null
Run Code Online (Sandbox Code Playgroud)
并出现编译错误
运算符“ ”不能应用于
<int>and类型的操作数null。
我怎样才能解决这个问题?
public PageBuildVrsn EditPageBuildVrsn(string caption, string nameInUse, string description, BuildAppStat bas = null, int pageBuildVrsnTypeId = 1)
{
PageBuildVrsn pbv = Create(pageBuildVrsnTypeId, caption, nameInUse, description);
pbv.ParentBuildAppStats = new List<BuildAppStat>();
pbv.ParentBuildAppStats.Add(
BasFactory.Create(
DateTimeOffset.Now,
true,
sourceId: bas.BuildAppStatId ?? null
)
);
return pbv;
}
Run Code Online (Sandbox Code Playgroud) 我有一张名为Rule的表.
RuleId Name
1 A1
2 A2
3 A3
.
.
.
Run Code Online (Sandbox Code Playgroud)
现在我希望所有的名字都是单一的结果.
可能会像 @allnames = A1,A2,A3
有人可以建议如何在不使用循环的情况下为此编写查询吗?
提前致谢...
我有以下查询获取Name和TotalPoints如下:
var gradeData = (from data in oAngieCtxt.prc_ShopInstanceCustomersData(Convert.ToInt32(this.ShopInstanceID), 10000, false)
.Where(row => row.RecievedPoints != "n/a")
.GroupBy(row => new { row.Name })
.Select(g => new
{
TotalPoints = g.Sum(x => Convert.ToDouble(x.RecievedPoints) * (x.Weightage.ToString() == "0.00" ? 1 : Convert.ToDouble(x.Weightage))),
Name = g.Key.Name
})
select data).ToList();
Run Code Online (Sandbox Code Playgroud)
我将有如下数据:
TotalPoints Name
5 A
10 B
5 C
15 D
5 E
Run Code Online (Sandbox Code Playgroud)
如果我们观察上面的列表5是最常见的.我必须从"gradeData"获取该值.
我怎么能得到它?