我正在使用asp.net mvc 5和C#with Entity Framework ...我有函数的模型和域类...现在我需要使用存储过程....我正在努力运动.
我遵循代码第一个现有的数据库,我有存储过程写在那里.我的问题是如何在我的Web应用程序中调用该存储过程.
存储过程:
ALTER PROCEDURE [dbo].[GetFunctionByID](
@FunctionId INT
)
AS
BEGIN
SELECT *
FROM Functions As Fun
WHERE Function_ID = @FunctionId
END
Run Code Online (Sandbox Code Playgroud)
域类:
public class Functions
{
public Functions()
{
}
public int Function_ID { get; set; }
public string Title { get; set; }
public int Hierarchy_level { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
功能模型:
[Table("Functions")]
public class App_Functions
{
public App_Functions()
{
}
[Key]
public int Function_ID { get; set; }
[StringLength(50)]
[Required]
public string …Run Code Online (Sandbox Code Playgroud) asp.net-mvc stored-procedures entity-framework repository-pattern
我正在研究.NET CORE 1.0 MVC 6应用程序,我坚持调试点,因为它昨天停止了打击.尝试我删除项目,然后重新开始.第一次加载符号,即使我在工具 - >调试 - >符号中取消选中,但它会命中断点.现在只有在我选择"启用我的代码"但在控制器中才能点击C#类'Startup.cs'.我从下拉列表中获得了调试选项,但不确定原因.需要帮助.
我换了
但仍然没有成功
public class HomeController : Controller
{
public IActionResult Index()
{
var x = 2 + 3;
return View();
}
public IActionResult About()
{
var x3 = 2 + 6;
var xx = "dd";
ViewData["Message"] = "Your application description page.";
return View();
}
Run Code Online (Sandbox Code Playgroud)
我为配置服务获取null异常.我正在使用Entity Framework 1.1,之前使用的是核心1.0并且没有问题,不知道我在这里缺少什么
{System.ArgumentNullException: Value cannot be null.
Parameter name: connectionString
at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
at Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(D bContextOptionsBuilder optionsBuilder, String connectionString, Action`1 sqlServerOptionsAction)
at App.WebDashboard.Startup.<ConfigureServices>b__4_0(DbContextOptionsBuilder options)
at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action`2 optionsAction)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass16_0.<RealizeService>b__0(ServiceProvider provider)
at Microsoft.Extensions.Internal.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
at lambda_method(Closure , IServiceProvider , Object[] )
at Microsoft.AspNetCore.Mvc.Internal.TypeActivatorCache.CreateInstance[TInstance](IServiceProvider serviceProvider, Type implementationType)
at Microsoft.AspNetCore.Mvc.Controllers.DefaultControllerFactory.CreateController(ControllerContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, …Run Code Online (Sandbox Code Playgroud) 我正在研究.NET CORE,实体框架核心.我有需要从.NET类执行的存储过程.我的存储过程需要多个'Context',我不知道如何处理这个,虽然我有dataView,这是最后的例外.
我是否可以使用我的dataView而不是context.dataModel类,当前实现(Context.Claims.FromSql)
public class ClaimDataView
{
public Guid ClaimId { get; set; }
public int IdNum { get; set; }
public string Value { get; set; }
public DateTime ExpirationDate { get; set; }
public ClaimAttributionActions Action { get; set; }
public bool ActiveStateForRole { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
public Guid UserId { get; set; }
public Guid ClientId { get; set; }
public Guid ConsultationId { get; set; }
var userParam = new SqlParameter("@UserVal", UserId);
var …Run Code Online (Sandbox Code Playgroud) 我已经实现了剑道ComboBox,但努力获得选定的价值....
$("#_FeeScheme_Input").kendoComboBox({
minLength: 1,
filter: 'contains',
dataTextField: "FeeSchemeDescription",
dataValueField: "FeeSchemeID",
select: onSelect,
dataSource: {
type: "json",
serverFiltering: false,
transport: {
read: "/Qualification/GetAllFeeScheme_JSON"
},
}
});
Run Code Online (Sandbox Code Playgroud)
...
function onSelect(e) {
var dataItem = this.dataItem(e.item.index());
alert("value " + dataItem.text); //NOT WORKING... RETURN NULL VALUE
};
Run Code Online (Sandbox Code Playgroud)
<div class="form-group">
@Html.LabelFor(model => model._FeeScheme.FeeSchemeDescription, new { @class = "control-label col-md-3" })
<div class="col-md-6">
@Html.TextBoxFor(model => model._FeeScheme.FeeSchemeDescription, new { id = "_FeeScheme_Input" })
@Html.ValidationMessageFor(model => model._FeeScheme.FeeSchemeDescription)
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试为ASP.NET MVC应用程序安装kendo UI,我收到了以下错误.htmlhelper不包含kendo的定义
我使用kendo ui工作ASP.NET项目,我在require文件夹中复制了require kendo样式和脚本,在web.config中添加了名称空间详细信息,在bundleConfig.cs中添加了引用,并在引用中添加了kendo.mvc dll.我已经按照以下教程
http://docs.telerik.com/kendo-ui/aspnet-mvc/asp-net-mvc-5
我不是我所缺少的,这两个应用程序都是ASP.NET MVC 5.
测试代码如下,我试图让它工作
@(Html.Kendo().DatePicker().Name("datepicker"))
Run Code Online (Sandbox Code Playgroud) 我试图从表中删除记录,store但我DeleteObject在我的代码中有识别问题.我有参考
using System.Linq;
using System.Data.Entity;
using System.Data.Objects;
Run Code Online (Sandbox Code Playgroud)
但它仍然无法正常工作.我正在MVC 4使用Visual Studio 2012.
public void Delete()
{
using (var db = new AppContext())
{
var query_D = (from b in db.Stores
where b.storeID == 1
select b).First();
db.DeleteObject(query_D);
db.SaveChanges();
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢
我有一个带有图像、标签和输入复选框的 div。当我点击 div 时,我喜欢什么,它会将复选框状态从 true 更改为 false ,并且反之亦然
jQuery
$(".markerDiv").click(function () {
if ($(this).find('input:checkbox[name=markerType]').is(":checked")) {
$(this).find('input:checkbox[name=markerType]').attr("checked", false);
}
else {
$(this).find('input:checkbox[name=markerType]').attr("checked", true);
}
alert($(this).find('input:checkbox[name=markerType]').is(":checked"));
});
Run Code Online (Sandbox Code Playgroud)
html
<div class="markerDiv" id="maker_school"><label class="marker_label">School</label> <input class="marker_ckeckbox" name="markerType" value="school" type="checkbox" /> </div> <br />
Run Code Online (Sandbox Code Playgroud) 我正在研究项目,并且我需要发送javaScript数组“ selectedZonesList”,将数据与表单数据一起返回给控制器。有人给我建议使用Ajax.BeginForm ...但是我正在努力地将所有部分集结起来,非常感谢...
@using (Html.BeginForm("CreateNewFeeScheme", "Qualification", FormMethod.Post, new { id = "NewFeeSchemeForm" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
//rest of code to take user input for all variables ..
<input type="submit" value="Create" class="btn btn-default" />
}
Run Code Online (Sandbox Code Playgroud)
<script type="text/javascript">
var selectedZonesList = new Array();
function AddFeeZoneToScheme(e)
{
var entityGrid = $("#FeeZoneGrid_02").data("kendoGrid");
var selectedZone = entityGrid.dataItem(entityGrid.select());
selectedZone = selectedZone.FeeZoneID;
selectedZonesList.push(selectedZone);
}
</script>
Run Code Online (Sandbox Code Playgroud)
[HttpPost]
public ActionResult CreateNewFeeScheme(FeeScheme newSchemeData, ??????)
{
Run Code Online (Sandbox Code Playgroud) 我在部分剃刀视图上使用 $ajax jquery 函数来获取另一个部分视图以及从控制器到页面的强类型模型数据--> 在特定 div 中显示。现在,如果数据模型数据在那里,它可以工作,但如果没有模型数据,我将传递 json 响应,以便我可以检查 razor 视图以避免空异常。我的问题是 $ajax 中的 done 方法没有调用加上 json 响应,我不知道我哪里做错了
$(document).ready(function () {
/*Address*/
$.ajax({
url: '@Url.Action("DisplayStudentAddress")',
type: "GET",
cache: false
}).done(function (data, textStatus, jqXHR) {
alert(data.Response);
$('#studentAddressDisplay').html(data);
}).fail(function (jqXHR, textStatus, errorThrown) {
alert(jqXHR +" "+textStatus+" "+errorThrown);
});
});
Run Code Online (Sandbox Code Playgroud)
[HttpGet]
[Authorize]
public ActionResult DisplayStudentAddress()
{
int _studentEntityID = 0;
_studentEntityID = _studentProfileServices.GetStudentIDByIdentityUserID(User.Identity.GetUserId());
Address _studentAddressModel = new Address();
_studentAddressModel = _studentProfileServices.GetStudentAddressByStudentID(_studentEntityID);
if (_studentAddressModel != null)
{
return PartialView("DisplayStudentAddress_Partial", _studentAddressModel);
} …Run Code Online (Sandbox Code Playgroud)