我有一个网站,每个用户的页面显示注释,并允许其他用户添加注释.我想拥有它,所以添加注释表单在页面上,当用户添加注释时,它将被添加到数据库并显示在带有AJAX的注释部分中.我正在使用jQuery for AJAX和LINQ to SQL来处理数据库逻辑.如何做到这一点,以便在将注释添加到数据库之后,注释部分会刷新并更新而不刷新页面?
在VS2010发布时,我在4月份看到了关于Stack Overflow上的L2S与EF4的一些讨论,即:
现在已经发布了Entity Framework 4.0的Linq-To-Sql?
现在,经过6个月,大概人们已经与EF4进行了更多的交互,所以我对新观点感到好奇,特别是在考虑只使用SQL Server时.
我经常使用LINQ to SQL,并且只使用了EF4.我不介意跳进去学习更多的EF4,我不相信,如果我的应用程序只与SQL Server交谈,那值得额外的复杂性.
所以,如果你对这两者都有一些经验,那么你现在要开始一个新的中小型应用程序,使用SQL Server后端,你会选择哪一个?
当然,为什么......
方法就是这个,EntityBase.Get:
public class EntityBase
{
public int Id;
public static T Get<T>(int id) where T : EntityBase
{
DataContextExtender extender = new DataContextExtender();
return extender.DataContext.GetTable<T>().Where(t => t.Id == id).FirstOrDefault();
}
}
Run Code Online (Sandbox Code Playgroud)
我想怎么用它:
Event ev = Event.Get(EventId)
Run Code Online (Sandbox Code Playgroud)
,其中Event继承EntityBase.
该方法自行编译,就像它一样,但如果我想以这种方式使用它,我会得到一条错误消息:
无法从用法推断出方法'RiotingBits.Data.Entities.EntityBase.Get(int)'的类型参数.尝试显式指定类型参数.
我知道我可以使用它Event.Get<Event>(EventId),但我真的想用它'我的方式'.该方法的代码无关紧要,我怀疑可能有一种方法可以提示该方法如何推断出正确的类型.
我是MVC架构的新手,我正在努力获得Button onclick.请帮我跟踪一下这个问题.我有一个Telerik TreeView控件,它已填充.一些节点具有子节点,而其中一些节点没有.
请告诉我需要做些什么更改才能解决这个问题在这里,我正在努力让它发挥作用.
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/PostLogin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<applications>>" %>
<%@ Import Namespace="ApplicationGrps" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<script runat="server" type="text/javascript">
protected void Page_Load()
{
ApplicationGrps.Visible = true;
ApplicationGrps.DataSource = ODS1;
ApplicationGrps.DataFieldID = "ApplicationName";
ApplicationGrps.DataFieldParentID = "ParentID";
ApplicationGrps.DataBind();
BindCheckedTags(ApplicationGrps);
}
protected void BindCheckedTags(RadTreeView treeView)
{
// Displays the checked nodes
}
protected void ODS2_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
e.InputParameters["ClientID"] = ViewData["ClientID"];
}
protected void btnSave_Click(object sender, EventArgs e)
{
//Iterate through the tree and get all the nodes …Run Code Online (Sandbox Code Playgroud) 我在db Time Parameter(00:15),StartTime(09:00),EndTime(15:00)中有3列
现在我希望在09:00到15:00之间以00:15的分钟显示所有时间
我应该写什么查询,以便它返回如下所示的值:
09:00 - 09:15
09:15 - 09:30
09:30 - 09:45
-
-
-
-
14:45 - 15:00
Run Code Online (Sandbox Code Playgroud) 我正在使用asp.net 4.
我需要为所有Panels WebControl设置一个页面的可见性为false
uxTypesDisplayer.Visible = false;
Run Code Online (Sandbox Code Playgroud)
我需要为所有这个面板设置可见性,而不需要为每个面板提供单个ID.
你知道伙计们怎么做吗?谢谢
这一行可能出现的错误是什么:
double bx;
Run Code Online (Sandbox Code Playgroud)
bx我定义普遍!但我在编译时遇到上述错误.Even for float bx; 我得到了同样的错误.
周围的代码是:
#include "header.h"
#include "ball_pad.h"
#include "pingpong.h"
#include "texture.h"
#include "3dsloader.h"
float A = 90.0f;
float B = 70.0f;
/**********************************************************
*
* VARIABLES DECLARATION
*
*********************************************************/
// The width and height of your window, change them as you like
int screen_width=640;
int screen_height=480;
// Absolute rotation values (0-359 degrees) and rotation increments for each frame
double rotation_x=0, rotation_x_increment=0.1;
double rotation_y=0, rotation_y_increment=0.05;
double rotation_z=0, rotation_z_increment=0.03;
// Absolute rotation values (0-359 degrees) and rotation …Run Code Online (Sandbox Code Playgroud) 我正在阅读一本书中的枚举,并给出了以下代码示例:
namespace FunWithEnums
{
enum EmpType : byte
{
Manager = 10,
Grunt = 1,
Contractor = 100,
VicePresident = 9
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("**** Fun with Enums *****");
EmpType emp = EmpType.Contractor;
EvaluateEnum(emp);
Console.ReadLine();
}
static void EvaluateEnum(System.Enum e)
{
Array enumData = Enum.GetValues(e.GetType());
for (int i =0; i < enumData.Length; i++)
{
Console.WriteLine("Name: {0}, Value: {0:D}", enumData.GetValue(i));
}
Console.WriteLine();
}
}
Run Code Online (Sandbox Code Playgroud)
我对于在forloop中打印出来的内容感到非常困惑.输出是
姓名:Grunt,价值:1
姓名:副总统,价值:9
姓名:经理,价值:10
名称:承包商,价值:100
但它如何获得每个枚举元素的名称和值?根据Microsoft文档,Array enumData = Enum.GetValues(e.GetType());应该只返回"指定枚举中的常量值的数组".我假设通过常数,它指的是"经理","咕噜","承包商","副总统",而不是10,1,100和9.那么为什么它返回每一对而不仅仅是名称员工类型?此外,以下代码的输出 …
c# ×3
sql-server ×2
asp.net ×1
asp.net-mvc ×1
c++ ×1
dom ×1
enumeration ×1
enums ×1
generics ×1
javascript ×1
jquery ×1
linq-to-sql ×1
web-controls ×1