LCD开发笔记-技术点总结

开发技术总结:
一、数据迁移
1、模型更改后:
1.1Enable-migrations
1.2修改实体对象
add-migration 修改的标记名称
1.3update-database
2、添加模型:
2.1将实体添加到上下文
add-migration 添加的标记名
update-database

二、规约
[Required]
[key.DatabaseGenerated(DatabaseGeneratedOption.Identity]
[MaxLength(15)]
[DatabaseGenerated(DataGeneratedOption.Identity]//新加入时
computed(更新时和加入时)
[Column(TypeName=“imgage”)]
http://www.cnblogs.com/Gyoung/archive/2013/01/17/2864150.html
三、日期时间
C# DateTime逊数的各种显示效果
http://blog.csdn.net/chwei_cson/article/details/7722233
http://blog.csdn.net/scimence/article/details/51488233
3.1默认时间
public DateTime createTime
{
get
{
return this.dateCreated.HasValue
? this.dateCreated.Value
: DateTime.Now;
}

        set { this.dateCreated = value; }

}

private DateTime? dateCreated = null;

3.2时间格式1
http://www.cnblogs.com/Pickuper/articles/2058880.html
DateTime dt;
DateTimeFormatInfo dtFormat=new System.Globalization.DateTimeFromateInfo();
dtFormat.ShortDatePattern=“yyy/mm/dd”
dt=convert.ToDateTime("2017/05/26“,dtFormat);

3.3时间格式3
shared/displyTemplate/ShortDateTime
@model System.DateTime
@{
Layout = null;
}
@Model.ToShortDateString()
显示时:@Html.DisplayFor(modelItem=>item.Dostime,“LongDateTime”);

3.4时间格式4
http://blog.csdn.net/hmillet/article/details/51434564
[Display(Name=“publishTime”)]
[DisplayFormat(DataFormatString="{0:yyyy/MM/dd}"]
public virtual System.DateTime PostTime
{
get;
set;
}
四、c# 使用Entity Framework操作Access数据库

Entity Framework是C#开发中最常见的ORM工具。默认Entity Framework只提供支持MSSQL的provider factory 。但是开发者开源贡献了对SQLite、MySql以及Access等的支持
JetEntityFrameworkProvider为Access数据库文件兼容Entity Framework提供了相应的 Provider 。在nuget中直接搜索JetEntityFrameworkProvider即可安装该工具

https://www.connectionstrings.com/ace-oledb-12-0/
http://blog.csdn.net/metal1/article/details/72820261
https://www.connectionstrings.com/ace-oledb-12-0/info-and-download/

DAL实例化
using JetEntityFrameworkProvider;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace BMW.DAL
{
public class accessDbContext:DbContext
{
private static string con = WebConfigurationManager.ConnectionStrings[“DefaultConnection”].ConnectionString;

    ***public accessDbContext() : base(new JetConnection(con), true) { }***
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        // base.OnModelCreating(modelBuilder);
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
    }
    }

web.config中



部署注意:
Framework4.5;
安装AccessDataBaseEngine.exe
配置windows\Microsoft.Net\framework\4.0…\config\machine.config

<system.data>



</system.data>

五、C#对象与JSON格式

从一个Json串生成对象信息
using Newtonsoft.Json;
List processTimes = new List();
processTimes = JsonConvert.DeserializeObject<List>(cycleTime.timesJson.Substring(0, cycleTime.timesJson.Length));
return PartialView(processTimes);
view视图
@model IEnumerable<B.Models.ProcessTime>
@foreach (var item in Model)
{

@item.processNameEn
@item.processCode
@item.processTime

}
http://www.cnblogs.com/wangchuang/archive/2012/07/19/2599472.html

http://blog.csdn.net/xy_int/article/details/53608857

六、MVC控制器向View传值的三种方法
6.1把一个对象作为View方法的参数传递给视图
public ViewResult Index()
{
DateTime date = DateTime.Now;
return View(date);
}
view
@{
ViewBag.Title = “Index”;
}

Index

The day is: @(((DateTime)Model).DayOfWeek) 或 @model DateTime @{ ViewBag.Title = "Index"; }

Index

The day is: @Model.DayOfWeek

6.2使用ViewBag(视图包)传递数据
public ViewResult Index()
{
ViewBag.Message = “Hello”;
ViewBag.Date = DateTime.Now;
return View();
}

@{
ViewBag.Title = “Index”;
}
Index
The day is: @ViewBag.Date.DayOfWeek

The message is: @ViewBag.Message

6.3使用View Data传递数据
public ViewResult Index()
{
ViewData[“Message”] = “Hello”;
ViewData[“Date”] = DateTime.Now;
return View();
}
@{
ViewBag.Title = “Index”;
}

Index

The day is: @(((DateTime)ViewData["Date"]).DayOfWeek)

The message is: @ViewData["Message"]

七、Ajax Helper或Jquery异步加载部分视图
7.1通过jQuery异步加载部分视图
http://www.jb51.net/article/75584.htm
index.html
@section scripts {

页面刷新的方式加载部分视图方法包括:

Html.RenderPartial()
Html.RenderAction()

public ActionResult GetItemTree(string title, int itemid, int? page) { pp = new PagingParam(page ?? 1, VConfig.WebConstConfig.PageSize); Common.Page.PagedList<Entity.Res_Item_Resource_R> res_Item_Resource_R = iResourceService.GetRes_Item_Resource_RByItemId(itemid, pp); ViewData[“res_Item_Resource_R”] = res_Item_Resource_R; res_Item_Resource_R.AddParameters = new System.Collections.Specialized.NameValueCollection(); res_Item_Resource_R.AddParameters.Add(“title”, title); res_Item_Resource_R.AddParameters.Add(“itemid”, itemid.ToString()); ViewResult vr = new ViewResult { ViewData = ViewData, MasterName = “”, }; return vr; }

$(function () {   var id = '<%=itemid %>';   $.ajax({    type: "POST",    url: "/Student/GetItemTree",    data: { title: '<%=Model.Name %>', itemid: id, page: 1 },    beforeSend: function (data) { //取回数据前     $("#itemTree").html('<span style="padding:5">数据加载中...</span>');    },    error: function (data) { //发生错误时 //    debugger;    },    success: function (data) { //成功返回时     $("#itemTree").html(data);    }   }); 

八、Supporting OData Actions in ASP.NET Web API 2
https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/odata-v3/odata-actions

九、背景的扩展
jquery-backstretch
https://github.com/jquery-backstretch/jquery-backstretch#transitions

十、服务器主动推送数据给客户端
10.1https://docs.microsoft.com/en-us/aspnet/signalr/index
10.2数据库触发
http://www.c-sharpcorner.com/blogs/the-sql-server-service-broker-for-the-current-database-is-not-enabled-and-as-a-result-query-notifications-are-not-supported-please-enable-the-service-broker-for-this-database-if-you-wish-to-use-not1
10.3教程
http://www.cnblogs.com/humble/p/3850749.html
10.4时时推送数据库的变化
http://blog.csdn.net/yanggenxiang/article/details/52415794
10.5单例模式的泛型实现 C#
http://blog.csdn.net/wuha555/article/details/40983297
https://www.2cto.com/kf/201412/363550.html
https://blog.csdn.net/qq_28368039/article/details/88350907
十一、C#之构造函数
http://www.cnblogs.com/jiajiayuan/archive/2011/09/08/2171422.html

十二、Html5+CSS3的响应式网页设计:自动适应屏幕
https://yusi123.com/2539.html

十三、MVC5通过HttpWebRequest上传图片
https://www.lanhusoft.com/Article/406.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值