的DbContext
public class HaberPortalDB : DbContext
{
public DbSet<Haberler> Haberler { get; set; }
public DbSet<Kategoriler> Kategoriler { get; set; }
public DbSet<Yazarlar> Yazarlar { get; set; }
}
public class Haberler
{
public virtual int Id { get; set; }
public virtual string Baslik { get; set; }
public virtual string Aciklama { get; set; }
public virtual string Icerik { get; set; }
public virtual int YazarId { get; set; }
public virtual Yazarlar Yazar { get; set; …Run Code Online (Sandbox Code Playgroud) 模型
[MetadataType(typeof(UserMetaData))]
public class User
{
public int Id { get; set; }
public string UserName { get; set; }
}
public class UserMetaData
{
public int Id { get; set; }
[Required(ErrorMessageResourceType = typeof(Resources.ModelValidation), ErrorMessageResourceName = "UserNameRequired")]
[LocalizedDisplayNameAttribute("UserName", NameResourceType = typeof(Resources.ModelValidation))]
public string UserName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
视图
@using (Html.BeginForm())
{
<div>
@Html.LabelFor(x => x.UserName)
@Html.TextBoxFor(x => x.UserName)
@Html.ValidationMessageFor(x => x.UserName)
</div>
<div>
<input type="submit" value="Gönder" />
</div>
}
Run Code Online (Sandbox Code Playgroud)
LocalizedDisplayNameAttribute
public class LocalizedDisplayNameAttribute : DisplayNameAttribute
{
private …Run Code Online (Sandbox Code Playgroud) VS 不记得这个选项是勾选的,当重新启动 IDE 或更改项目分支时。
当我打开 IDE 时,我总是选中这个选项。
我正在使用 VS 17 Enterprise 最新版本。
编辑:我也在使用 resharper(也许它会覆盖 VS 选项)。
我创建了一个mvc4网络应用程序.用剃刀视图引擎.您知道布局页面和内容页面(主页,联系人,关于等).但是没有引用内容页面的布局.
内容页面不应包括:
Layout = "~/Views/Shared/_Layout.cshtml";
Run Code Online (Sandbox Code Playgroud)
在内容页面中,这段代码丢失了.它们有效.没有布局参考,它如何做到这一点?
我写了这段代码.但我想忽略时间,我只想比较一天.
from s in sayac_okumalari
where s.okuma_tarihi == startDate && s.sayac_id == sayac_id
group s by new { date = new DateTime(((DateTime)s.okuma_tarihi).Year, ((DateTime)s.okuma_tarihi).Month, ((DateTime)s.okuma_tarihi).Day, ((DateTime)s.okuma_tarihi).Hour, 1, 1) } into g
select new
{
okuma_tarihi = g.Key.date,
T1 = g.Sum(x => x.toplam_kullanim_T1),
T2 = g.Sum(x => x.toplam_kullanim_T2),
T3 = g.Sum(x => x.toplam_kullanim_T3)
};
Run Code Online (Sandbox Code Playgroud)
例如:
25.02.1987 == 25.02.1987
Run Code Online (Sandbox Code Playgroud) 我想使用谷歌geochart与坐标(longtitute,latitute).但是我找不到关于这个主题的任何例子.区域和城市的例子有很多例子.但是我找不到坐标.
请,代码示例,链接,教程别的什么?
谢谢.
例如,我想以特定的时间间隔(每小时或每日任务)调用一个函数.
我已经在使用Timer了.但只要我的本地服务器正常工作,它就能工作.例如:
public static void StartYahooWeatherManager()
{
Timer t = new Timer(1000 * 60 * 60 * 6 /* 6 hours */);
t.Elapsed += new ElapsedEventHandler(WriteYahoWeatherRssItemToDb);
t.Start();
}
private static void WriteYahoWeatherRssItemToDb(object o, ElapsedEventArgs e)
{
YahooWeatherManager.InsertYahooWeatherRssItem(YahooWeatherManager.GetYahooWeatherRssItem());
}
Run Code Online (Sandbox Code Playgroud)
我以6小时为间隔向db发送天气信息.项目已经在主持人.只要我的计算机本地服务器正在运行,Timer事件就会起作用.
题:
我的代码有什么问题?(或者在WebProject中使用计时器的逻辑错误?)为什么计时器只在本地服务器工作时工作?
管理时间间隔任务的最佳方法是什么?(不需要asp.net)
我希望,我可以解释这个问题.谢谢.
我将使用asp.net中的文件上传控件上传文件.现在我想使用java脚本获取没有扩展名的文件名.我想验证文件名应该只是整数格式
$(function () {
$('#<%=File1.ClientID %>').change(function () {
var uploadcontrol = document.getElementById('<%=File1.ClientID%>').value;
})
})
Run Code Online (Sandbox Code Playgroud) 消息:System.InvalidOperationException:Mapper未初始化.使用适当的配置调用Initialize.如果您正试图通过容器或以其它方式使用映射器实例,请确保您不必静态Mapper.Map方法的任何电话,如果你使用ProjectTo或UseAsDataSource扩展方法,确保你在适当的IConfigurationProvider通实例.
定义映射配置文件(ApplicationMappingProfile.cs)
public class ApplicationMappingProfile : Profile
{
public ApplicationMappingProfile()
{
CreateMap<User, UserListDto>();
CreateMap<Permission, PermissionListDto>();
// add auto mapper mapping configurations here
}
}
Run Code Online (Sandbox Code Playgroud)
注册automapper服务(ApplicationServiceCollectionExtensions.cs)
public static class ApplicationServiceCollectionExtensions
{
public static IServiceCollection AddKodkodApplication(this IServiceCollection services)
{
services.AddAutoMapper();
//todo: add conventional registrar
services.AddTransient<IUserAppService, UserAppService>();
services.AddTransient<IPermissionAppService, PermissionAppService>();
return services;
}
}
Run Code Online (Sandbox Code Playgroud)
创建一个测试服务器以运行Startup.cs(ApiTestBase.cs)
public class ApiTestBase : TestBase
{
protected static HttpClient Client;
public ApiTestBase()
{
//if this is true, Automapper is throwing …Run Code Online (Sandbox Code Playgroud) 脚本
function PostExportValues(meter_id, range_type_id, start_date, end_date, returnUrl) {
var meter = $("#meter_selection").val()[0];
$.ajax({
url: '@Url.Action("GridExportToExcel", "Widget")',
type: 'POST',
data: { MeterType: meter_id, DateRangeType: range_type_id, StartDate: start_date, EndDate: end_date, returnUrl: returnUrl, Meter: meter },
success: function () {
alert("Success.");
},
error: function () {
alert("Error!");
}
}); //end ajax
} //end PostExportValues
Run Code Online (Sandbox Code Playgroud)
CONTROLLER
public void GridExportToExcel(int MeterType, int DateRangeType, DateTime? StartDate, DateTime? EndDate, string returnUrl, int Meter)
{
Customers customer = CustomerManager.GetCustomer(WebSecurity.CurrentUserId);
//if start date is null, then set it to …Run Code Online (Sandbox Code Playgroud) asp.net-mvc ×4
c# ×4
.net ×2
asp.net ×1
asp.net-core ×1
automapper ×1
datetime ×1
file-upload ×1
idisposable ×1
javascript ×1
linq ×1
localization ×1
razor ×1
timer ×1
unit-testing ×1