我正在为现有的第三方应用程序构建自定义。我的代码在同一个.NET应用程序池中运行,并与第三方应用程序位于同一服务器上。
我没有访问他们的数据模型,也没有api。我一直在编写SQL查询并为我的自定义开发WCF服务。这有效,但感觉“很糟糕”。以下是一个例子:
public DLPDetail GetEventDetail(int id)
{
DLPDetail detail = new DLPDetail();
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["DLP"].ToString());
con.Open();
SqlCommand command = new SqlCommand("SELECT compound_path, FILE_MATCH_ID FROM E_ABSTRACT_FILE_MATCH WHERE EVENT_ID = '" + id + "'", con);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
detail.Name = reader.GetString(0);
detail.FileMatchId = reader.GetInt64(1).ToString();
}
return detail;
}
我想知道是否有更好的方法可以使用类似实体框架之类的东西。有什么想法吗?
答案 0 :(得分:3)
一些建议: