我正在寻找在我正在开发的几个应用程序中实现一些更好的方法来使用List.我目前的实现看起来像这样.
MyPage.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
BLL.PostCollection oPost = new BLL.PostCollection();
oPost.OpenRecent();
rptPosts.DataSource = oArt;
rptPosts.DataBind();
}
Run Code Online (Sandbox Code Playgroud)
BLL班级
public class Post
{
public int PostId { get; set; }
public string PostTitle { get; set; }
public string PostContent { get; set; }
public string PostCreatedDate { get; set; }
public void OpenRecentInitFromRow(DataRow row)
{
this.PostId = (int) row["id"];
this.PostTitle = (string) row["title"];
this.PostContent = (string) row["content"];
this.PostCreatedDate = (DateTime) row["createddate"];
}
}
public class PostCollection : …Run Code Online (Sandbox Code Playgroud) 我有一些函数使用SqlCommand对象来进行数据插入和查询.但是一个函数(文件中的最后一个函数)似乎将(大部分)属性回显到输出中.有问题的功能:
function Add-DataStudentChangeEvent($person,
$key,
$currentValue,
$newValue,
$eventType){
$cmdEvent=New-Object System.Data.SqlClient.SqlCommand
$cmdEvent.Connection = $conn
$cmdEvent.CommandTimeout = 600000
$cmdEvent.CommandText = "INSERT INTO ChangeEvent
(AttributeKey
,CurrentAttributeValue
,NewAttributeValue
,EventType
,EventDate
,CompletedStatus
,Person_Id)
VALUES
(@AttributeKey,
@CurrentAttributeValue,
@NewAttributeValue,
@EventType,
GETDATE(),
0,
@PersonId);" -F
$cmdEvent.Parameters.AddWithValue("@AttributeKey", $key);
$cmdEvent.Parameters.AddWithValue("@CurrentAttributeValue", $current);
$cmdEvent.Parameters.AddWithValue("@NewAttributeValue", $updateTo);
$cmdEvent.Parameters.AddWithValue("@EventType", $eventType);
$cmdEvent.Parameters.AddWithValue("@PersonId", $person);
$cmdEvent.ExecuteNonQuery()
}
Run Code Online (Sandbox Code Playgroud)
在使用参数化查询的另一个类似函数中,我发现-F在最后添加,停止回声.我确实说过大部分参数.实际上只显示了5个中的4个.这是我得到的输出:
1
CompareInfo : None
XmlSchemaCollectionDatabase :
XmlSchemaCollectionOwningSchema :
XmlSchemaCollectionName :
ForceColumnEncryption : False
DbType : String
LocaleId : 0
ParameterName : @CurrentAttributeValue
Precision : 0
Scale : 0
SqlDbType …Run Code Online (Sandbox Code Playgroud) 我一直在研究如何使用 JavaScript 将名称设置为正确的大小写,例如,george mchall 会变成 George McHall。我在 Codeproject 上找到了一篇关于如何做到这一点的文章,以及一个打算这样做的人:
function toProperCase(s){
return s.toLowerCase().replace( /\b((m)(a?c))?(\w)/g,
function($1, $2, $3, $4, $5) {
if($2){
return $3.toUpperCase()+$4+$5.toUpperCase();
}
return $1.toUpperCase();
});
}
Run Code Online (Sandbox Code Playgroud)
这允许我正在寻找的东西。但我需要能够进一步扩展它并添加更多案例。
我在约翰·格鲁伯的网站上找到了另一个页面,其中包含标题大小写,但我只关注名称。
那么,有人有延长它的想法吗?我真的只是在寻找正确方向的一个点。
编辑:因为我似乎在这里碰壁了,也许有人有办法在服务器端做到这一点。至少目前在服务器端使用 ColdFusion。我已经看到了 C# 实现,但目前无法转向 C#。