我有一个Visual Studio 2010项目,我引用了一个指向本地版本的程序集Oracle.DataAccess.dll.
我已经明确地将选项"Specific Version"设置为false但是在构建应用程序时我已经检查了应用程序程序集并且它具有对
Oracle.DataAccess,Version = 2.112.3.0,Culture = neutral,PublicKeyToken = 89b483f429c47342
如何引用特定版本的程序集?
我想依赖bin文件夹中可用的版本.
它目前显然取决于应用程序的构建位置.如果我在安装了不同版本的Oracle客户端的计算机上构建项目,则主应用程序中将包含不同的Oracle.DataAccess版本控制引用.
它不应该依赖于应用程序的构建位置.它不应该引用任何特定版本.
我需要加载一个包含很多孩子和孩子孩子的非常大的物品清单.什么是最好的方法?
我正在使用Oracle 11g数据库,我编写了以下方法,但它产生了笛卡尔积(重复结果):
public IList<ARNomination> GetByEventId(long eventId)
{
var session = this._sessionFactory.Session;
var nominationQuery = session.Query<ARNomination>().Where(n => n.Event.Id == eventId);
using (var trans = session.Transaction)
{
trans.Begin();
// this will load the Contacts in one statement
nominationQuery
.FetchMany(n => n.Contacts)
.ToFuture();
// this will load the CustomAttributes in one statement
nominationQuery
.FetchMany(n => n.CustomAttributes)
.ToFuture();
// this will load the nominations but joins those two tables in one statement which results in cartesian product
nominationQuery
.FetchMany(n => n.CustomAttributes)
.FetchMany(n => …Run Code Online (Sandbox Code Playgroud) 我有一个有大约20个属性的类,但我会为这个问题简化它:
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我想要一个班级或财产,以确定我的班级是否脏.我的意思是确定它的任何值是否已经改变?
我可以采取3种设计方法:
1)在类中设置属性时,我检查属性是否为IsDirty.
public string Name
{
get { return this._name; }
set { if (this._name != value) { this.IsDirty = true; this._name = value; }
}
Run Code Online (Sandbox Code Playgroud)
2)当从类外部设置属性时,我检查属性IsDirty.
例如
if (p.Name != newName)
{
p.IsDirty = true;
p.Name = newName;
}
Run Code Online (Sandbox Code Playgroud)
这种方法迫使我在客户端类中添加大量ifs.有些属性甚至是集合甚至是引用对象,因此行数甚至会增加.
3)当对象准备好保存时,我通过获取克隆对象并检查相等性来检查是否有任何属性IsDirty.
这会有较差的性能,因为我必须克隆或再次加载原始对象,然后逐个比较属性.
哪一个是最好的设计?或者是否有任何其他设计模式可以帮助解决这个问题?
我有一个只能在调试模式下运行的代码。
使用 HttpContext.Current.IsDebuggingEnabled 或“#if DEBUG ... #endif”更好吗?
谢谢,
我有一个表格,其标题出现在表格顶部。
我需要另一个标题出现在表格底部。怎么可能呢?
<table>
<caption>My Table - Start</caption>
<tbody></tbody>
<tfooter></tfooter>
<caption>My Table - End</caption>
</table>
Run Code Online (Sandbox Code Playgroud) 我有一个带有以下构造函数的Order类
public Order(IProduct product, short count)
{
this._product = product;
this._count = count;
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试设置Unity IoC容器,显然要构建我需要知道计数和产品的订单对象,但这些是在运行时确定的; 计数可以是任何价值,产品可以是任何产品,例如胡萝卜,甜瓜等.
那么如何应用IoC呢?
我认为一种方法是我的构造函数只接受对象依赖,然后使用新的Initialize()方法添加任何其他必需的属性:
public Order (IProduct product)
{
this._product = product;
}
public Initialize(short count)
{
this._count = count;
}
Run Code Online (Sandbox Code Playgroud)
以这种方式创建Order对象的人必须在之后调用Initialize()方法,以便将IoC容器无法处理的其他属性添加到其中.
这是你推荐/使用的方法吗?
c# asp.net ioc-container inversion-of-control unity-container
我有一个xml文件,其结构如下:
<connections>
<connection>
<serverName>serverName1</serverName>
<dbName>dbName1</dbName>
</connection>
</connections>
Run Code Online (Sandbox Code Playgroud)
我有一个新的连接作为文本数据,如下所示:
var xml="<connection><serverName>serverName2</serverName><dbName>dbName2</dbName></connection>";
var xDocument = XDocument.Load(HttpContext.Current.Server.MapPath(this.XmlDataFilePath));
Run Code Online (Sandbox Code Playgroud)
我怎么能将这个新节点插入我的文档?
我尝试了这个,但它失败了:
xDocument.Root.AddAfterSelf(xml);
xDocument.Save(HttpContext.Current.Server.MapPath(this.XmlDataFilePath));
Run Code Online (Sandbox Code Playgroud)
谢谢,
我有一个方法如下:
public bool IsValid(decimal rate)
{
//
}
Run Code Online (Sandbox Code Playgroud)
速率可以在0.00到99.99之间,它不应该包含超过2个小数位,否则它应该抛出异常.
如何检查十进制值是否不超过2个小数点?例如99.123无效而99.12无效.
如何向Visual Studio 2010 Professional Edition SP1添加HTML5 Intellisense支持?
我安装了这个:http://visualstudiogallery.msdn.microsoft.com/d771cbc8-d60a-40b0-a1d8-f19fc393127d但没有任何反应.
例如,当我<convas在页面的Visual Studio源视图上键入时,我希望列出其属性列表等.
我有一个使用Selenium创建的测试方法,类似于:
[TestFixture]
public class Test_Google
{
IWebDriver driver;
[SetUp]
public void Setup()
{
driver = new InternetExplorerDriver();
}
[TearDown]
public void Teardown()
{
driver.Quit();
}
[Test]
public void TestSearchGoogleForTheAutomatedTester()
{
//Navigate to the site
driver.Navigate().GoToUrl("http://www.google.co.uk");
//Find the Element and create an object so we can use it
IWebElement queryBox = driver.FindElement(By.Name("q"));
//Work with the Element that's on the page
queryBox.SendKeys("The Automated Tester");
queryBox.SendKeys(Keys.ArrowDown);
queryBox.Submit();
//Check that the Title is what we are expecting
Assert.True(driver.Title.IndexOf("The Automated Tester") > -1);
}
} …Run Code Online (Sandbox Code Playgroud) testing selenium windows-services webbrowser-control system-testing
c# ×5
asp.net ×4
.net ×2
html ×2
build ×1
caption ×1
css ×1
debugging ×1
decimal ×1
future ×1
html-table ×1
html5 ×1
intellisense ×1
linq ×1
linq-to-xml ×1
nhibernate ×1
oracle ×1
orm ×1
selenium ×1
testing ×1
validation ×1
versioning ×1
xml ×1