小编dcp*_*ers的帖子

如何设置这样的常量 - Constants.Page.Title.MyCase - 在C#中?

我正在尝试如何设置如何设置

Color.RGG.Black等于"#000000"

我试图使它类似,并实现到我的常量类.我该怎么做呢?

Constants.Page.Title.MyCase 等于 "My Case";

谢谢

c# enumeration constants

1
推荐指数
1
解决办法
110
查看次数

在C#中用List <>替换ArrayList

我正在广泛使用ArrayList并且难以使用此List <>.我使用EntitySpace ORM来做DAL的事情.这个东西很好用,但问题是我必须用对象类型定义List <>,抱怨它不能转换它.

非常感谢你的帮助.

原始使用ArrayList:

public ArrayList Get()
    {
        TndCustomerTendersCollection collection = new TndCustomerTendersCollection();
        collection.Query
        .Select
        (
            collection.Query.CustomerTenderID,
            collection.Query.CustomerTenderID,
            collection.Query.CustomerTenderCode,
            collection.Query.CustomerTenderName,
            collection.Query.StartDate,
            collection.Query.DueDate,
            collection.Query.CompleteDate,
            collection.Query.DateCreated,
            collection.Query.LastDateModified
        )
        .Where
        (
            collection.Query.IsActive.Equal(true)
        );

    ArrayList list = new ArrayList ();
        foreach (TndCustomerTenders item in collection)
        {
            list.Add(item);
        }
        return list;
    }
Run Code Online (Sandbox Code Playgroud)

用List替换后

public List<Tender> Get()
    {
        TndCustomerTendersCollection collection = new TndCustomerTendersCollection();
        collection.Query
        .Select
        (
            collection.Query.CustomerTenderID,
            collection.Query.CustomerTenderID,
            collection.Query.CustomerTenderCode,
            collection.Query.CustomerTenderName,
            collection.Query.StartDate,
            collection.Query.DueDate,
            collection.Query.CompleteDate,
            collection.Query.DateCreated,
            collection.Query.LastDateModified
        )
        .Where
        (
            collection.Query.IsActive.Equal(true)
        );

        // HOW DO CONVERT …
Run Code Online (Sandbox Code Playgroud)

c#

1
推荐指数
1
解决办法
3321
查看次数

如何识别TSQL中的大写和小写字?

我们需要以某种方式区分所有大写字母和标题字,例如:

[Column 1]
Kenya
MELBOURNE
Japan
SYDNEY
CANBERRA
WOLLONGONG
United States
United Kingdoms
Run Code Online (Sandbox Code Playgroud)

首都词是指城市,标题词是指国家.

我们一直在寻找其他专栏来区分这些事情,但这是我们能想到的情感因素.

t-sql sql-server

1
推荐指数
1
解决办法
2104
查看次数

如何修改文件夹的上次写入时间和上次访问时间

我们需要更改与服务器上许多文件夹的上次写入时间和上次访问相关的文件夹属性。

我们发现通过运行 Powershell 来做到这一点,如下所示:

set-itemproperty -Path C:\testsource\folder1 -Name LastWriteTime -Value ((get-date).adddays(-90))
Run Code Online (Sandbox Code Playgroud)

如您所见,get-date 方法正在添加 adddays 的内容。是否有任何功能可以将精确设置为“2013-05-03 11:31”最多一分钟?

原因是我有这个确切的日期,例如从以前的备份“2013-05-03 11:31”,需要替换“2015-03-12 18:31”,因为你可以看到设置 addminute 是否很有挑战性因为我们正在处理数百个文件夹。

感谢您的投入。

powershell

1
推荐指数
1
解决办法
2437
查看次数

如何在_Layout.cshtml共享Razor页面中添加配置设置

我们有StartUp如下获取值appsettings.json

public Startup(IHostingEnvironment env)
{
    var builder = new ConfigurationBuilder()
        .SetBasePath(env.ContentRootPath)
        .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
        .AddEnvironmentVariables();
    Configuration = builder.Build();

    var environment = Configuration["ApplicationSettings:Environment"];
}

public void ConfigureServices(IServiceCollection services)
{
    services.Configure<AppSettings>(Configuration.GetSection("ApplicationSettings"));

    ...
}
Run Code Online (Sandbox Code Playgroud)

我们也模型叫 AppSettings

public class AppSettings
{
    public string Environment { get; set; }
    public string Version { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

由于我正在/Pages/Shared/_Layout.cshtml尝试将此版本注入到此共享页面中,因此我无法执行代码隐藏方法。那怎么注入呢?

更新 1 -

理论上,如果它是页面模型,我可以这样做:

public class _LayoutModel : PageModel
{
    private readonly AppSettings _appSettings; …
Run Code Online (Sandbox Code Playgroud)

.net-core asp.net-core razor-pages

1
推荐指数
2
解决办法
3311
查看次数

单班和班级收藏

我总是编写引用一个对象作为单个类的编码,如果我想获得该类的集合,我只使用Get()并返回列表.

public abstract class Customer
{
   private Int32 customerID;
   private String customerName;

   public abstract List<Customer> Get();
   public abstract bool Add();
   public abstract bool Update();
   public abstract bool Delete();
}
Run Code Online (Sandbox Code Playgroud)

现在......我收到了其他关于这个的评论,我应该创建另一个集合类来迎合这个.我也特别在ORM(对象关系映射)的东西中看到过这个但是不是太多了吗?

所以它会是这样的:

public abstract class CustomerCollection
{    
   public abstract List<Customer> Get();
   public abstract bool Add();
   public abstract bool Update();
   public abstract bool Delete();
}
Run Code Online (Sandbox Code Playgroud)

你对此有何看法?

谢谢

c# oop

0
推荐指数
1
解决办法
201
查看次数

如何获取最新更新的记录?

我在MySQL中有如下记录

RecID| LastModified
1 | 2011-10-29
1 | 2011-11-29
2 | 2011-5-29
3 | 2011-6-28
3 | 2011-8-25
Run Code Online (Sandbox Code Playgroud)

我想要这样的结果:

RecID| LastModified
1 | 2011-11-29
2 | 2011-5-29
3 | 2011-8-25
Run Code Online (Sandbox Code Playgroud)

我如何在MySQL中执行此操作?

谢谢

mysql

0
推荐指数
1
解决办法
3649
查看次数

了解非SQL数据库上的移动应用程序上的Azure轻松表

基于此博客 - https://blog.xamarin.com/getting-started-azure-mobile-apps-easy-tables/,该示例始终将SQL作为数据库与Easy Tables结合使用.我们尝试过使用Storage帐户而不是SQL数据库.这还有可能吗?

每次我们设置此项时,我们总会得到"您当前的App Service应用程序不支持Easy Tables.请初始化您的App Service应用程序以获得Easy Tables支持." 看起来它不支持存储帐户.有人可以验证吗?

xamarin azure-mobile-services

0
推荐指数
1
解决办法
1101
查看次数