我正在使用Entity Framework作为我的ORM连接两个SQL函数.当查询执行时,我收到以下错误消息:
The query attempted to call 'Outer Apply' over a nested query,
but 'OuterApply' did not have the appropriate keys
Run Code Online (Sandbox Code Playgroud)
这是我的查询:
var ingredientAllergenData = (from ings in db.fnListIngredientsFromItem(productId, (short)itemType, productId)
join ingAllergens in db.fnListAllergensFromItems(productId.ToString(CultureInfo.InvariantCulture), (short)itemType, currentLang)
on ings.id equals ingAllergens.ingredientId into ingAllergensData
from allergens in ingAllergensData.DefaultIfEmpty()
where ings.table == "tblIng" || ings.table == ""
select new {ings, allergens}).ToList();
Run Code Online (Sandbox Code Playgroud)
我在LINQPad中写了相同的查询,我得到了结果,所以我不确定是什么问题:
var ingredientAllergenData = (from ings in fnListIngredientsFromItem(1232, 0, 1232)
join ingAllergens in fnListAllergensFromItems("1232", 0, 1)
on ings.Id equals ingAllergens.IngredientId into …Run Code Online (Sandbox Code Playgroud) 我无法绑定包含对象列表的模型.当我尝试将数据从控制器传递到视图时没有问题,但是当我想要发回数据时,我得到一条消息,表明该方法不存在.
我正在使用ajax调用,并且作为数据我放了$ form.serialize()并且可以看到包含fiddler中所有数据的列表,但是我对绑定没有运气.
该模型是:
public class Single
{
public int Id {get;set;}
public string Name {get;set;}
public List<SimpleDropdown> dddl {get;set;}
public int SelectedEmp {get;set;}
}
public class MainModel
{
public List<Single> main_model_list {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,现在的方法是:
[HttpPost]
public string SaveModel(MainModel model)
{
return "";
}
Run Code Online (Sandbox Code Playgroud)
此方法不会被调用,但是当我删除调用的参数时.所以我确定绑定不起作用.我有一个更复杂的模型,但我尽可能简化它,仍然无法让它工作.
所以我的问题是如何测试这个以查看问题是什么?
编辑:
我目前没有代码,但该代码功能正常,因为我在项目的其他地方使用它.它是这样的:
$("#form").submit(function( ) {
$.ajax({
url: "/Controller/SaveModel",
type: "POST",
data: $(this).serialize()
});
});
Run Code Online (Sandbox Code Playgroud)
表单看起来像这样:
@using (Html.BeginForm("SaveModel", "Home", FormMethod.Post, new { id = "form" }))
{
@for (var z = 0; z < ViewBag.groupes.Length; …Run Code Online (Sandbox Code Playgroud) 如上所述,这种情况发生在Safari中,而在Chrome和Firefox中它运行良好.
我认为这是因为变成json的对象有两个包含moment对象的属性.我将它们更改为日期对象并stringify传递了函数.
奇怪的是,如果我尝试这样做JSON.stringify(moment())是有效的,所以我不知道如何调试它并找到问题所在.
以下是Safari中错误的屏幕截图:

编辑:
经过一些调试后,我发现dhtmlxwindow onclose事件发生后会发生此错误.我在一个dhtmlx窗口中加载一个局部视图,在那里我创建了这个对象,在关闭窗口之前,该对象被推入一个初始化为父视图的列表中.
在我关闭窗口之前我做了,JSON.stringify(parent.addedContracts)并且在onclose事件发生后它工作正常(我没有覆盖代码)列表具有相同的对象(我检查了所有属性)但是stringify同一列表失败.
编辑:
创建添加到列表中的对象如下:
var contractStartDate = moment(contractStartDateCalendar.getDate(true), "L");
var contractEndDate = moment(contractEndDateCalendar.getDate(true), "L");
var newContract = {
Id : uniqueId,
FunctionDesc : $("#contractFunction").val(),
ContractHours : $("#contractHours").val(),
AdditionalCostFactor: $("#contractAdditionalCostFactor").val().replace(',', '.'),
VacationFormula : contractHolidayCostFactor,
StartDate : contractStartDate,
EndDate : contractEndDate,
Notes : Encoder.htmlEncode(tinyMCE.get('contractNotes').getContent()),
DaysOfWeek : workingDaysString,
PlusMinus : $("#contractTypeDropdown option:selected").data("plusminus"),
SalaryCalculation : $("#contractTypeDropdown option:selected").data("salarycalculation"),
ContractTypeId : $("#contractTypeDropdown").val(),
ContractTypeName : $("#contractTypeDropdown option:selected").text(), …Run Code Online (Sandbox Code Playgroud) 我的问题是在exec中使用表变量.
declare @sort_col nvarchar(1000) = 'itm_id'
declare @sort_dir nvarchar(4) = 'desc'
declare @filters nvarchar(1000) = ' and itm_name like ''%aa%'''
declare @temp table
(
itm_id int
)
insert into @temp
EXEC('select itm_id from Tblitm where itm_name not like ''%aa%''')
EXEC('select * from (select (ROW_NUMBER() OVER (ORDER BY '+@sort_col+' '+@sort_dir+')) row_num, * FROM (select itm_id, itm_name,
dbo.fnItmsHistory(itm_id) itm_history
from dbo.Tblitm as itm
left outer join '+@temp+' as temp on itm.itm_id = temp.itm_id
where itm_id=itm_id and temp.itm_id = null '+@filters+') as x) …Run Code Online (Sandbox Code Playgroud) 我有多个员工的每日数据,并且根据可能意味着大量数据的开始时间和结束时间.
因此,使用映射插件,我将它们映射到一个大的列表,但我需要将它们按员工分组到较小的列表中,这样我就可以为每个员工制作一个表(如较小的视图模型),该表对该数据子集进行过滤和排序.
这是我用静态数据创建的基本示例.
$(function () {
var data = {
Employees: [{
Id: 1,
Name: "Employee1",
Day: new Date(),
Price: 12.54
}, {
Id: 2,
Name: "Employee2",
Day: new Date(),
Price: 112.54
}, {
Id: 1,
Name: "Employee1",
Day: new Date(),
Price: 12.54
}, {
Id: 3,
Name: "Employee3",
Day: new Date(),
Price: 12.54
}]
};
// simulate the model to json conversion. from now on i work with the json
var jsonModel = JSON.stringify(data);
function employeeModel(data) {
var employeeMapping …Run Code Online (Sandbox Code Playgroud).net javascript asp.net-mvc knockout-mapping-plugin knockout.js
我从外部webapi获取带有json对象的字符串.我有一个代码将对象放入ExpandoObject列表,但必须有另一个解决方案,而不使用动态对象.
这是代码:
System.Net.HttpWebRequest request =
(System.Net.HttpWebRequest)System.Net.WebRequest.Create("https://example.com/api/users.json");
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
request.Headers["Authorization"] = "API key="+somekey;
// Ignore Certificate validation failures (aka untrusted certificate + certificate chains)
System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader reader = new StreamReader(resStream);
//response from the api
string responseFromServer = reader.ReadToEnd();
//serialize the data
var jss = new System.Web.Script.Serialization.JavaScriptSerializer();
System.Collections.IList users = (System.Collections.IList)((IDictionary<string, object>)((IDictionary<string, object>)jss.DeserializeObject(responseFromServer))["data"])["users"];
List<System.Dynamic.ExpandoObject> api_users = new List<System.Dynamic.ExpandoObject>();
//putting the expandable objects in list
foreach (var …Run Code Online (Sandbox Code Playgroud) 我需要在特定单元格中缩进文本.特定单元格是包含子项的xml元素.
我的XML是:
<rows>
<row id="FOLDER1">
<cell image="blank.gif">Folder 1</cell>
<cell/>
<cell/>
<cell/>
<cell/>
<cell/>
<cell/>
<cell sum="1">$23</cell>
<row id="FOLDER2">
<cell image="blank.gif">Folder 2</cell>
<cell/>
<cell/>
<cell/>
<cell/>
<cell/>
<cell/>
<cell sum="2">$11</cell>
<row id="FOLDER3">
<cell image="blank.gif">Folder 3</cell>
<cell/>
<cell/>
<cell/>
<cell/>
<cell/>
<cell/>
<cell sum="3">$44</cell>
<row id="pro1">
<cell image="blank.gif">Product 1</cell>
<cell>324234</cell>
<cell>3.00</cell>
<cell>Kilo</cell>
<cell>1.00</cell>
<cell>No</cell>
<cell>euro 33.33</cell>
<cell>euro 33.33</cell>
</row>
<row id="pro2">
<cell image="blank.gif">Product 2</cell>
<cell>4354354</cell>
<cell>1.00</cell>
<cell>Kilo</cell>
<cell >0.50</cell>
<cell>No</cell>
<cell>euro 2.53</cell>
<cell>euro 1.26</cell>
</row>
</row>
<row id="pro3">
<cell image="blank.gif">Product 3</cell>
<cell>435436</cell> …Run Code Online (Sandbox Code Playgroud) c# ×3
.net ×2
asp.net-mvc ×2
javascript ×2
ajax ×1
asp.net ×1
c#-4.0 ×1
dhtmlx ×1
jquery ×1
json ×1
knockout.js ×1
linq ×1
linq-to-sql ×1
momentjs ×1
safari ×1
spreadsheet ×1
sql ×1
sql-server ×1
t-sql ×1
xml ×1
xslt ×1
xslt-1.0 ×1