我有一个模型,其中包含2个不同的列表,例如:
public IList<PurchaseOrderPreliminaryDesignModel> DesignList { get; set; } = new List<PurchaseOrderPreliminaryDesignModel>();
public IList<PurchaseOrderPreliminaryVendorModel> VendorList { get; set; } = new List<PurchaseOrderPreliminaryVendorModel>();
public PurchaseOrderPreliminaryDesignViewModel AddDesignList(IEnumerable<PurchaseOrderPreliminaryDesignModel> model)
{
((List<PurchaseOrderPreliminaryDesignModel>)DesignList).AddRange(model);
return this;
}
public PurchaseOrderPreliminaryDesignViewModel AddVendorList (IEnumerable<PurchaseOrderPreliminaryVendorModel> model)
{
((List<PurchaseOrderPreliminaryVendorModel>)VendorList).AddRange(model);
return this;
}
所以我使用方法填写第一个列表:
public PurchaseOrderPreliminaryDesignViewModel GetPreliminaryDesignList(string jobNumber)
{
try
{
PurchaseOrderPreliminaryDesignViewModel DoGetDesigns()
{
using (var connection = _connectionManager.GetOpenConnection(_configuration.GetConnectionString(FirstConnectionString)))
{
var rModel = new PurchaseOrderPreliminaryDesignViewModel();
var designList = connection.Query<PurchaseOrderPreliminaryDesignModel>("[dbo].[usp_PurchaseOrder_Preliminary_Design]", param: new
{
LegacyKey = jobNumber
}, commandType: CommandType.StoredProcedure);
rModel.AddDesignList(designList);
return rModel;
}
}
return DoGetDesigns();
}
catch (Exception ex)
{
throw ex;
}
}
如您所见,我在FirstConnectionString
方法中使用using
,因此我连接到一个数据库来填写第一个列表。现在,我想填写其他列表,但使用不同的连接。
我的问题是如何连接第二个字符串以填充其他列表?我的意思是在相同的用途中做类似的事情:
var vendorList = connection2.Query<PurchaseOrderPreliminaryVendorModel>("mystore", param: new
{
Parameter = jobNumber
}, commandType: CommandType.StoredProcedure);
然后返回使用,例如:
rModel.AddDesignList(designList).AddVendorList(vendorList);
return rModel;
我该如何实现?问候
答案 0 :(得分:2)
<style id="s" type="text/html">
<div class="r">
<p>{%= o.rand %}</p>
<script>
console.log('sdf');
</script>
</div>
</style>