上一页 1 ··· 5 6 7 8 9 10 11 下一页

MVC中JQuery文件引入的路径问题,@Url.Content函数

摘要: 今天写了个MVC的Demo,文件夹结构很简单,如下:利用EF生成Model框架并手工加表字段注解,但在页面上JS验证始终没显示。实在无语。无意中在浏览器里按F12,看见提示:Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:1445/~/Scripts/jquery.validate.min.jsFailed to load resource: the server responded with a status of 500 (Internal Ser 阅读全文
posted @ 2014-03-11 19:06 nlh774 阅读(3017) 评论(0) 推荐(0)

EF的表连接方法Include()

摘要: 在EF中表连接常用的有Join()和Include(),两者都可以实现两张表的连接,但又有所不同。例如有个唱片表Album(AlbumId,Name,CreateDate,GenreId),表中含外键GenreId连接流派表Genre(GenreId,Name)。每个唱片归属唯一一个流派,一个流派可以对应多个唱片。1.Join(),两表不必含有外键关系,需要代码手动指定连接外键相等(具有可拓展性,除了值相等,还能指定是>, Join(this IQueryable outer, IEnumerable inner, Expression> outerKeySelector, Exp 阅读全文
posted @ 2014-03-09 00:21 nlh774 阅读(18436) 评论(3) 推荐(0)

在使用EFCodeFirst中出现类型“System.Data.Objects.ObjectContext”在未被引用的程序集中定义的解决方案

摘要: 我安装了EF4.1版本,并在一个项目中映射一个数据库并生成了EF的MODEL实体层测试:在Default.aspx页面上加了个GridView控件,后台进行绑定 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.UI; 6 using System.Web.UI.WebControls; 7 using WebApp1.Models; 8 9 namespace WebApp110 {11 public part... 阅读全文
posted @ 2014-03-08 15:33 nlh774 阅读(1195) 评论(0) 推荐(0)

总结下遇到的C#新语法

摘要: 1.属性的private set读写器public int x { get; private set; }是另一种简写, set前面的private声明是告诉编译器属性X是只读(read-only)的. 意思是对于外部类不能通过属性X给x赋值,而只能读取其值。例子: 1 public class PswChangingEventArgs : EventArgs 2 { 3 public readonly string message; 4 5 public PswChangingEventArgs(string _message) 6 ... 阅读全文
posted @ 2014-02-22 18:07 nlh774 阅读(460) 评论(0) 推荐(0)

MVC3下的layout页面

摘要: 1.Layout页基础:如果你有使用MasterPage的经验,你将会记得如下的几个东西A:B:C:D:但是在Layout中,以上的这些东西将会消失.(作者不排除有WebPages和WebForms兼容工作的可能性)取而代之的新功能是:A.Layout属性:等同于原来的MasterPageFile属性.B.@RenderBody()方法:直接渲染整个View到占位符处,而不需要原来所使用的.C.@RenderPage()方法:渲染指定的页面到占位符处.D.@RenderSection方法:声明一个占位符,和原来的功能类似.E.@section标记:对@RenderSection方法声明的占位符 阅读全文
posted @ 2014-02-22 18:01 nlh774 阅读(466) 评论(0) 推荐(0)

C#委托初探

摘要: 委托是一种定义方法签名的类型,可以与具有兼容签名的任何方法关联。您可以通过委托调用其中已添加的方法列表。委托用于将方法作为参数传递给其他方法。事件处理程序就是通过委托调用的方法。您可以创建一个自定义方法,当发生特定事件时某个类(例如 Windows 控件)就可以调用您的方法。button的单击事件发生后,通过委托这个管道找到用户添加的处理方法,从而执行方法;不必像之前win32程序那样循环等待某个事件消息。先直接添端代码进来, 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using Sys 阅读全文
posted @ 2014-01-02 09:29 nlh774 阅读(2460) 评论(0) 推荐(0)

CSS的display属性,显示或隐藏元素

摘要: This is a headerxxxxxxxxxxxxxxxxxxxxxxxxxxThis is some text. This is some text. This is some text.This is some text. This is some text. This is some text.This is some text. This is some text. This is some text. 阅读全文
posted @ 2013-12-30 18:00 nlh774 阅读(509) 评论(0) 推荐(0)

c#循环迭代匿名类链表(可迭代的匿名类)

摘要: Main(){ //为什么?object是基类啊!! //报错。不能从List换成List. //var q=(List)GetWholeProcessInfo(); //Console.WriteLine(q[0].ToString()); int i = 1; foreach (var item in (IEnumerable)GetWholeProcessInfo()) { //类型都一样... 阅读全文
posted @ 2013-12-24 21:01 nlh774 阅读(536) 评论(0) 推荐(0)

LINQ延迟查询的例子

摘要: 1 //linq延迟查询。两次查询结果不同 2 List l = new List() { "aaa", "bbb", "ccc" }; 3 var query = l.Select(lstr => new { Name = lstr.ToString() }); //延迟查询,此时还未真正查询产生query 4 foreach (var item in query) //查询真正开始 5 { 6 Console.WriteLine(it... 阅读全文
posted @ 2013-12-24 20:47 nlh774 阅读(259) 评论(0) 推荐(0)

C#窗体:关于DataGridView的数据源绑定字符串两个值得注意的问题

摘要: 无意间遇到的问题,然后就GOOGLE了下,搜到些资料,总结整理如下(注:是转载的)1. LINQ的查询结果无法直接作为DataGridView的数据源DataGridView的DataSource属性为object类型,但并不意味着任何类型都可以作为DataGridView的数据源。DataGridView的数据源必须是实现以下接口的任意类型: (1)IList 接口,包括一维数组。 (2)IListSource 接口,例如,DataTable和DataSet类。 (3)IBindingList 接口,例如,BindingList类。 (4)IBindingListView 接口,例如,Bin 阅读全文
posted @ 2013-12-22 20:54 nlh774 阅读(412) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 下一页