我必须为应用程序构建新模型,而不是更好的方法:
使用继承或使用enum作为对象类型:
例如 :
图书
class Book
{
public string Name {get;set;}
public string Author {get;set;}
public int NumberOfPages {get;set;}
}
public class Encyclopedie:Book
{
}
public class Novel:Book
{
}
Run Code Online (Sandbox Code Playgroud)
或更好地使用:
class Book
{
public BookType Type {get;set;}
public string Name {get;set;}
public string Author {get;set;}
public int NumberOfPages {get;set;}
}
public enum BookType
{
Encyclopedie = 0,
Novel = 1,
...
}
Run Code Online (Sandbox Code Playgroud) 我有一个向数据库添加行的方法(sql server 2005).它的问题是因为当我有一行UpdateDate时2000-12-31 23:59:59 它会插入2001-01-01 00:00:00.000.可能吗?如果重要的话,环境文化是好的.这对我来说很神奇:/
private void AddInvestmentStatus(InvestmentData.StatusyInwestycjiRow investmentStatusesRow)
{
SqlCommand cmd = new SqlCommand("AddInvestmentStatus");
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param1 = new SqlParameter("@InvestmentId", SqlDbType.BigInt);
param1.Value = investmentStatusesRow.InvestmentId;
cmd.Parameters.Add(param1);
cmd.Parameters.AddWithValue("@enumInvestmentStatusID", investmentStatusesRow.EnumInvestmentStatusID);
cmd.Parameters.AddWithValue("@modifiedBy", "System");
cmd.Parameters.AddWithValue("@UpdateDate", investmentStatusesRow.UpdateDate);
cmd.Parameters.AddWithValue("@ModifiedOn", investmentStatusesRow.ModifiedOn);
cmd.Parameters.AddWithValue("@dataVersion", investmentStatusesRow.DataVersion);
cmd.Connection = new SqlConnection(MyProgram.Properties.Settings.Default.ConnectionString);
if (cmd.Connection.State != ConnectionState.Open)
cmd.Connection.Open();
try
{
cmd.ExecuteNonQuery();
}
catch (Exception e)
{
throw;
}
}
Run Code Online (Sandbox Code Playgroud)
}
create PROCEDURE [dbo].[AddInvestmentStatus]
@inwestmentID bigint,
@enumInvestmentStatusId bigint,
@updateDate datetime,
@dataVersion int,
@modifiedBy nvarchar(50),
@modifiedOn datetime
AS
BEGIN …Run Code Online (Sandbox Code Playgroud) 我在表中有一个错误的主键记录.我想将其更改为正确的值,但此值在许多其他表中使用.
是否有任何简单的方法来同时更新主键和外键?
我在SPGridView中看到了许多冻结列的例子,但我不知道为什么它们都不适合我.我的意思是 - 没有冻结.
我将很感激地看一下我的代码.
下面是准备启动的代码片段.它必须适用于IE 8+(其他浏览器无关紧要).
我将提供100分的解决方案,这将有效.
样式
/* Locks the left column */
td.locked, th.locked {
font-size: 7pt;
text-align: left;
background-color:inherit;
color:Black;
position:relative;
cursor: default;
left: expression(document.getElementById("div-datagrid").scrollLeft-2); /*IE5+ only*/
}
/* Locks table header */
th {
font-size: 7pt;
font-weight: bold;
text-align: center;
background-color: navy;
color: white;
height:15pt;
border-right: 1px solid silver;
position:relative;
cursor: default;
top: expression(document.getElementById("div-datagrid").scrollTop-2); /*IE5+ only*/
z-index: 10;
}
/*
div#div-datagrid {
width: 420px;
height: 200px;
overflow: auto;
scrollbar-base-color:#ffeaff;
}
*/
/*
.container
{
overflow:auto;
margin-left:10px; …Run Code Online (Sandbox Code Playgroud) 它有一个属性:字符串代码和其他10个.
公共代码是字符串列表(string [])汽车列表(Car [])filteredListOfCars是List.
for (int index = 0; index < cars.Length; index++)
{
Car car = cars[index];
if (commonCodes.Contains(car.Code))
{
filteredListOfCars.Add(car);
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这片方法的时间太长了.
我有大约5万条记录
我怎样才能降低执行时间?
我有一个枚举
class Nationality:
Poland='PL'
Germany='DE'
France='FR'
...
Spain='ES'
Run Code Online (Sandbox Code Playgroud)
我有2个方法原型:
# I want somethink like in c#
def convert_country_code_to_country_name(country_code):
print Enum.Parse(typeof(Nationality),country_code)
#this a second solution ,but it has a lot of ifs
def convert_country_code_to_country_name(country_code):
if country_code=='DE':
print Nationality.Germany #btw how to print here 'Germany', instead 'DE'
Run Code Online (Sandbox Code Playgroud)
这就是我想要调用这个方法的方法:
convert_country_code_to_country_name('DE') # I want here to print 'Germany'
Run Code Online (Sandbox Code Playgroud)
如何在python中实现它?
我想知道什么是最简单的方法来编写从1到50生成数字的方法,然后依赖于生成的数字返回我的字符串如:
Abcdef如果生成的数字为9,
Abcdefghi则生成的数字为6.
我正在使用python 3.2
我不能在同一个字段中添加几个值.我只能选择一个值,经过我的输入,,;或其它分隔符,我不能选择另外一个.我希望它的工作方式与自动完成类似.
我有一个jQuery绑定的文本框:
<div class="editor-field">
@Html.EditorFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name)
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#Name").autocomplete('@Url.Action("TagName", "Tag")', {
minChars: 1,
delimiter: /(,|;)\s*/,
onSelect: function(value, data){
alert('You selected: ' + value + ', ' + data);
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
它使用来自我的控制器的数据:
public ActionResult TagName(string q)
{
var tags = new List<TagModel>
{
new TagModel {Name = "aaaa", NumberOfUse = "0"},
new TagModel {Name = "mkoh", NumberOfUse = "1"},
new TagModel {Name = "asdf", NumberOfUse = "2"}, …Run Code Online (Sandbox Code Playgroud) 我用的是:
total_time=datetime.time(int(total_time_text.replace("h","").replace("m","").split(" ")[0]),int(total_time_text.replace("h","").replace("m","").split(" ")[1]),0)
Run Code Online (Sandbox Code Playgroud)
存储时间长度.
但是当我有:
total_time_text ="26h 50m"
Run Code Online (Sandbox Code Playgroud)
我得到一个例外
'hour must be in 0..23'
Run Code Online (Sandbox Code Playgroud)
所以类型"时间"不适合这个var.我必须使用什么?
我试图找出如何在SL中使用DispatcherHelperftom MVVM light toolkit,但我找不到任何示例.
从这个框架的主页我知道
DispatcherHelper类,一个轻量级类,可帮助您创建多线程应用程序.
但我不知道如何使用它.
如何以及我可以使用它?
c# ×3
python ×3
datetime ×2
css ×1
enums ×1
inheritance ×1
jquery ×1
modeling ×1
mvvm-light ×1
performance ×1
primary-key ×1
random ×1
razor ×1
sharepoint ×1
spgridview ×1
sql ×1