我在面试中被问了一个问题.如何使用从datareader返回的数据填充自定义对象.
我的回答是使用datareader.read(),创建自定义对象的实例并使用datareader值设置属性.
面试官并不高兴.他说,如果我有数百万条记录,那么使用我的方法填写这些记录将非常缓慢.他让我建议替代方式.
除此之外还有其他任何方式.请评论.
我有一个后台主题.如果后台线程忙,我想等待它完成其工作,然后继续下一个请求.我已通过以下方式实现它.Process是后台线程的名称.
if (process.IsBusy)
{
do
{
isProcessBusy = process.IsBusy;
} while (isProcessBusy == false);
SetIsDirty(status, GetContext());
}
else
{
SetIsDirty(status, GetContext());
}
Run Code Online (Sandbox Code Playgroud)
这是最好的方式还是有其他方法来实现这种逻辑?
我有一个接受的storedprocedure
@MissingRecordsXML NTEXT
Run Code Online (Sandbox Code Playgroud)
它包含XML记录.现在,另一位开发人员使用游标从OPENXML获取行,然后在每行上应用了所有业务规则,然后将每行插入表中.
我想知道在SQL Server中预测XML数据的最佳方法是哪种.我必须提高此SP的性能,因为当有多个记录时它很慢.Cursors已经被声明为只读.请帮助
从XML填充游标的代码是: -
exec sp_xml_preparedocument @hDocSEC OUTPUT,@MissingRecordsXML
DECLARE SEC_UPDATE CURSOR FOR
SELECT MissingColumn,TableName,PhysicalColName,Grantor_Grantee
FROM OPENXML (@hDocSEC,'MissingDS/MissingTable',2)
WITH (MissingColumn VARCHAR(1000),TableName VARCHAR(100),
PhysicalColName VARCHAR(100),Grantor_Grantee VARCHAR(100) )
OPEN SEC_UPDATE
FETCH NEXT FROM SEC_UPDATE
INTO @MissingColumn,@TableName,@ActualColumnName,@Grantor_Grantee
Run Code Online (Sandbox Code Playgroud) 我的窗体中有一个构造函数
public frmSecondarySEC(int intPrimaryDocumentId, int intSecondaryDocumentId, string strStateCode, int intCountyId, string strPrimaryDocTypeName, string strPrimaryDocTypeCode, string strDealName, string strLoanNumber, int intDealId, string strDealType, string strCountyName, bool blIsFileReview)
{
}
Run Code Online (Sandbox Code Playgroud)
现在我需要将一个额外的参数传递给这个构造函数.为此我创建了这个构造函数的重载版本,以便使用原始构造函数的其他类不会分解.只是添加了新参数.
public frmSecondarySEC(int intPrimaryDocumentId, int intSecondaryDocumentId, string strStateCode, int intCountyId, string strPrimaryDocTypeName, string strPrimaryDocTypeCode, string strDealName, string strLoanNumber, int intDealId, string strDealType, string strCountyName, bool blIsFileReview,string primaryDocumentTitle)
{
}
Run Code Online (Sandbox Code Playgroud)
现在,因为他们共享commom初始化代码,我尝试构造函数链接
public frmSecondarySEC(int intPrimaryDocumentId, int intSecondaryDocumentId, string strStateCode, int intCountyId, string strPrimaryDocTypeName, string strPrimaryDocTypeCode, string strDealName, string strLoanNumber,int intDealId, string strDealType, string strCountyName, …Run Code Online (Sandbox Code Playgroud) 我正在处理应用程序的前端.我必须再介绍一个过滤标准LoanNumber.现在贷款数量是E-100.业务层和域对象不在我的控制之下.所以我无法改变它.持有loannumber的域对象是整数,我必须这样做
ingeoFilterData.intLoanNumber="E-100"
Run Code Online (Sandbox Code Playgroud)
ingeoFilterData是域对象.intLoanNumber被声明为Nullable Int32现在这个domainobject是非常关键的,它转到一些外部引擎,所以我不能改变它.
请提出一些解决方法.
编辑-
我正在从数据库表中复制loannumber.
RT1
RT2
PT1
pt10
PT11
PT12
PT13
PT14
PT15
pt16
pt17
pt8
pt9
MDR1
MDR2
MDR3
Run Code Online (Sandbox Code Playgroud)