小编Dar*_*bio的帖子

流畅的NHibernate可视设计师

是否有类似于Mindscape的NHibernate设计师为Fluent NHibernate设计的视觉设计师?

我决定从EF4转移到NH3,但如果没有可视化设计界面,那么习惯于EF4模型创建界面的团队将会很难卖出.

nhibernate nhibernate-mapping fluent-nhibernate

5
推荐指数
0
解决办法
3884
查看次数

EmailAddressAtribute被忽略

我有一个类定义的属性EmailAddress与属性EmailAddressAttribute来自System.ComponentModel.DataAnnotations

public class User : Entity
{
    [EmailAddress]
    public string EmailAddress { get; set; }

    [Required]
    public string Name { get; set; }
}

public class Entity
{
    public ICollection<ValidationResult> Validate()
    {
        ICollection<ValidationResult> results = new List<ValidationResult>();
        Validator.TryValidateObject(this, new ValidationContext(this), results);
        return results;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我将的值设置为EmailAddress无效的电子邮件(例如'test123')时,该Validate()方法会告诉我该实体有效。

RequiredAttribute验证工作(例如,设置Namenull节目我一个验证错误)。

我如何EmailAddressAttribute在验证器中工作?

c# validation data-annotations

5
推荐指数
2
解决办法
381
查看次数

SELECT中的mySQL变量

是否可以进行如下查询:

SELECT
@threadIDvar = `threads`.`id` AS `threadID`,
(SELECT `posts`.`timeDate` FROM `posts` WHERE `posts`.`threadID` = @threadIDvar) AS `postDate`
FROM `threads`
INNER JOIN `posts` ON `posts`.`threadID` = `threads`.`id`
WHERE `threads`.`boardID` = 1
Run Code Online (Sandbox Code Playgroud)

我已经尝试了但是我将@threadID作为NULL返回,因此postDate也为NULL.

如何让变量@threadIDvar填充返回的threadID?

mysql sql t-sql

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

将图像添加到Monotouch.Dialog中的节

我使用MonoTouch.Dialog创建了一个视图,其中包含几个部分.这些部分需要在其他部分之前添加图像,但是我很难在第一部分之前将UIImage添加到该区域.

我该怎么做?我已经强调了RootElement中我想要Image的位置.

public void HomeScreen ()
    {
        var root = CreateRoot_HomeScreen ();

        var dv = new DialogViewController (root, true);
        navigation.PushViewController (dv, true);
    }

    RootElement CreateRoot_HomeScreen()
    {
        // Set up the ImageView with the Logo in it
        var logo = UIImage.FromFile("Images/logo.png");

        var imageView = new UIImageView(logo);

        return new RootElement("iEngage"){
            // The Image should go here
            new Section(){

            },
            new Section("")
            {
                new StyledStringElement ("Search", delegate{ Console.Write("Clicked"); })
            }
        };
    }
Run Code Online (Sandbox Code Playgroud)

c# xamarin.ios ios monotouch.dialog

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

LINQ使用左连接通过FK命令

我有以下代码:

from _categories in context.SCT_Categories
join _categoryOrders in context.SCT_CategoryOrders
on _categories.ID equals _categoryOrders.CategoryID into joinedData
from _categoryOrders in joinedData.DefaultIfEmpty()
orderby _categoryOrders.OrderIndex descending 
select _categories
Run Code Online (Sandbox Code Playgroud)

哪个左边连接类别和categoryOrders

对于每个catgoryOrder,都有一个类别.

这很有效,除了当我想通过OrderIndex(可以为null到999)进行排序时,它会在查询的顶部放置所有空(即null返回的关系,其中类别没有categoryOrder).

如何更改此值以将空值放在列表的末尾?在查询之后,优选地没有迭代将空值更改为999.

谢谢,

JD

.net c# linq-to-sql

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

在特定时间运行Windows服务

可以将Windows服务设置为在特定时间运行..?

From 8:00 am to 5:00pm run process 
From 5:00 pm to 8:00am run process
Run Code Online (Sandbox Code Playgroud)

此过程可以每天,每周或一天运行.

请让我知道你的想法

c# windows

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

jQuery-validation 1.9.0和jQuery 1.7.1

我已经使用jQuery 1.7.1在页面上设置了jQuery验证,如下所示.

<html>
<head>
    <script src="jquery-1.7.1.js" type="text/javascript"></script>
    <script src="jquery.validate-1.9.0.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#form1").validate();
        });
    </script>
</head>
<body>
    <form id="form1">
        <div>
            <p>
                <input id="form1input1" name="11" class="required" />
            </p>
            <p>
                <input id="form1input2" name="12" class="required email" />
            </p>

            <input type="submit" value="Validate form 1">
        </div>
    </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这些字段在提交表单时验证,但不在模糊/键盘上验证.

如果我为jQuery 1.3.2换掉jQuery 1.7.1,那么插件的工作方式就像模糊/ keyup验证一样.

这是兼容性问题吗?我在GitHub问题跟踪器中找不到任何错误/打开的门票https://github.com/jzaefferer/jquery-validation

jquery jquery-validate

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

IEnumerable <T> .ToLookup <TKey,TValue>

我试图使用以下代码IEnumerable<KeyValuePair<string, object>>变成一个ILookup<string, object>:

var list = new List<KeyValuePair<string, object>>()
{
    new KeyValuePair<string, object>("London", null),
    new KeyValuePair<string, object>("London", null),
    new KeyValuePair<string, object>("London", null),
    new KeyValuePair<string, object>("Sydney", null)
};

var lookup = list.ToLookup<string, object>(a => a.Key);
Run Code Online (Sandbox Code Playgroud)

但编译器抱怨:

实例参数:无法从'System.Collections.Generic.List>'转换为'System.Collections.Generic.IEnumerable'

'System.Collections.Generic.List>'不包含'ToLookup'的定义和最佳扩展方法重载'System.Linq.Enumerable.ToLookup(System.Collections.Generic.IEnumerable,System.Func)'有一些无效参数

无法从'lambda表达式'转换为'System.Func'

我对lambda表达式做错了什么?

c# linq lookup lambda

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

NHibernate映射哪些标识可以使用?

在选择与NHibernate一起使用的身份生成器时,我应该考虑什么?

例如简单流畅的映射:

Id(c => c.ID).GeneratedBy.HiLo("User");
Map(c => c.Username).Not.Nullable().Length(50);
Map(x => x.Password).Not.Nullable().Length(40);
Run Code Online (Sandbox Code Playgroud)

有了这个POCO:

public class User
{
    public virtual long ID { get; private set; } // This could be changed to GUID etc
    public virtual string Username { get; set; }
    public virtual string Password { get; set; }

    public User ()
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

这应该使用HiLo,uuid.hex,HiLoseq等......为什么?

nhibernate fluent-nhibernate

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

object [] to List <Interface>返回null

如果我有一个看起来像这样的物体:

class Person : IProxy
{
    // Properties
}
Run Code Online (Sandbox Code Playgroud)

我有一个方法返回一个object实际上是List<Person>:

object GetList()
{
    List<Person> people = new List<Person>();

    person.Add(new Person());
    person.Add(new Person());

    return people;
}
Run Code Online (Sandbox Code Playgroud)

为什么以下代码导致null?

var obj = GetList() as List<IProxy>;
Run Code Online (Sandbox Code Playgroud)

但是下面的代码返回一个List:

var obj = GetList() as List<Person>;
Run Code Online (Sandbox Code Playgroud)

在Visual Studio的Watch面板中,我的类型报告为:

object {System.Collections.Generic.List<Person>}
Run Code Online (Sandbox Code Playgroud)

c# generics interface

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

DateTime从具有指定格式的String解析

我正在尝试从中提取日期时间信息

"2012/04/03 10:06:21:611747"
Run Code Online (Sandbox Code Playgroud)

使用格式

String dateformat = @"yyyy/mm/dd hh:mm:ss:ffffff";
Run Code Online (Sandbox Code Playgroud)

获得例外 - 任何帮助表示赞赏.

完整代码

 String dateformat = @"yyyy/mm/dd hh:mm:ss:ffffff";
 readonly CultureInfo _provider = CultureInfo.InvariantCulture;
 DateTime dateTime = DateTime.ParseExact(line, dateformat, _provider);
Run Code Online (Sandbox Code Playgroud)

.net c#

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