小编Cur*_*Fro的帖子

如何在流畅的nhibernate中加入表

我们怎么做这个映射但流利?

<class name="Person" table="People">

    <id name="Id">
        <generator class="identity"/>
    </id>

    <property name="Name" />

    <join table="Addresses">
        <key column="PersonId"/>
        <property name="Line1"/>
        <property name="Line2"/>
        <property name="City"/>
        <property name="Country"/>
        <property name="ZipCode"/>
    </join>

</class>
Run Code Online (Sandbox Code Playgroud)

我知道我可以使用'参考',但我不需要相关表格中的所有列.我只需要一个房产.

nhibernate fluent

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

未知的鉴别器值C#Mongo

我能够将我的课程保存到mongo,但是我在反序列化时遇到错误.

我收到一个错误:

'MongoDB.Bson.BsonSerializationException:未知的鉴别器值'ProductPropertyDefinition'.'

我需要帮助.如何告诉mongo正确反序列化?

public class Product
{
    [BsonId]
    [BsonRepresentation(BsonType.ObjectId)]
    public string Id { get; set; }

    public ProductPropertyDefinitionCollection ProductProperties { get; set; }
}

public class ProductPropertyDefinitionCollection : CollectionBase
{
    public ProductPropertyDefinition this[int index]
    {
        get
        {
            return (ProductPropertyDefinition)List[index];
        }
        set
        {
            List[index] = value;
        }
    }

    public ProductPropertyDefinition this[string name]
    {
        get
        {
            return GetByName(name);
        }
    }

    public int Add(ProductPropertyDefinition value)
    {
        return List.Add(value);
    }

    public void Remove(ProductPropertyDefinition value)
    {
        List.Remove(value);
    }

    public bool Contains(ProductPropertyDefinition value)
    {
        return …
Run Code Online (Sandbox Code Playgroud)

c# mongodb

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

如何将Angular2 RC1与systemjs捆绑在一起

在发布之前,候选角度提供了捆绑文件.由于发布候选版本没有更多的捆绑文件.包括angular2和rxjs我的应用程序现在可以加载超过7秒的671个请求.这削弱了发展.

有谁知道如何捆绑angular和rxjs并将它们包含在system.config中?

bundle rxjs systemjs angular

13
推荐指数
2
解决办法
9007
查看次数

如何通过行索引和列索引获取单元格的值

目前我这样做:

string cellValue = sheet.get_Range("A12", _missing).Value2.ToString();
Run Code Online (Sandbox Code Playgroud)

这工作但我真的需要按行和列索引选择一个单元格.

我尝试时得到一个null异常

string cellValue = ((Range)sheet.Cells[row, column]).Value2.ToString();
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

c# excel

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

什么相当于邮政中的@ Html.Raw?

我正在从服务运行邮政.我的@Message有html.@ Html.Raw不可用.当Postal运行我的模板化视图时,我获得了HtmlEncoded html.有谁知道如何解决这一问题?

c# postal

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

如何重构这段代码?

我怎样才能将这些代码重构为一种方法或什么?

            if (!string.IsNullOrEmpty(_gridModel.Header))
                _gridModel.Header += ",";
            if (item != null)
                _gridModel.Header += item.Header;

            if (!string.IsNullOrEmpty(_gridModel.Width))
                _gridModel.Width += ",";
            if (item != null)
                _gridModel.Width += item.Width;

            if (!string.IsNullOrEmpty(_gridModel.Align))
                _gridModel.Align += ",";
            if (item != null)
                _gridModel.Align += item.Align;

            if (!string.IsNullOrEmpty(_gridModel.Filter))
                _gridModel.Filter += ",";
            if (item != null)
                _gridModel.Filter += item.Filter;

            if (!string.IsNullOrEmpty(_gridModel.Type))
                _gridModel.Type += ",";
            if (item != null)
                _gridModel.Type += item.Type;

            if (!string.IsNullOrEmpty(_gridModel.Sort))
                _gridModel.Sort += ",";
            if (item != null)
                _gridModel.Sort += item.Sort;
Run Code Online (Sandbox Code Playgroud)

.net c# refactoring

4
推荐指数
2
解决办法
422
查看次数

我该如何重构这段代码?

我有.net 3.5,我想制作一个通用的方法.我该如何重构这段代码?

            case (int)Enums.SandwichesHoagies.Cheeses:
                if (this.Cheeses.Where(x => x.Id == product.ProductId).SingleOrDefault() == null)
                {
                    var newCheese = new Cheese
                    {
                        Id = product.ProductId,
                        Name = product.Name,
                        PriceValue = product.Price.HasValue ? (double)product.Price.Value : 0.00
                    };

                    this.Cheeses.Add(newCheese);
                }
                else
                {
                    foreach (var cheese in this.Cheeses.Where(cheese => cheese.Id == product.ProductId))
                    {
                        this.Cheeses.Remove(cheese);
                        break;
                    }
                }

                foreach (var cheese in Cheeses) cheese.Type = string.Empty;

                if (this.Cheeses.Count > 0) Cheeses.First().Type = "Cheeses:";

                break;

            case (int)Enums.SandwichesHoagies.Meats:
                if (this.Meats.Where(x => x.Id == product.ProductId).SingleOrDefault() == null)
                {
                    var newMeat …
Run Code Online (Sandbox Code Playgroud)

c# linq asp.net generics refactoring

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

使用Ninject批量注册通用接口的所有实现

我在Castle Windsor注入了以下接口.我如何在Ninject中做同样的事情?

container.Register(
    AllTypes.FromAssemblyNamed("Apps.Web")
        .BasedOn(typeof(ICommandHandler<>))
        .WithService.FirstInterface());
Run Code Online (Sandbox Code Playgroud)

我试过了:

this.Bind(x => x.FromAssembliesMatching("Apps.Web.dll")
     .Select(y => y.Namespace.EndsWith("Handlers"))
     .BindSingleInterface());
Run Code Online (Sandbox Code Playgroud)

但是没有将Object引用设置为对象错误的实例.

.net ninject ioc-container ninject.web.mvc

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

我如何重构这些linq属性?

我有4个类属性,具有相似的签名,但具有不同的linq属性.我如何创建一个委托或其他东西来清理它?

例如:

    public IEnumerable<SelectListItem> DistinctUsers
    {
        get
        {
            var list = TraceLogs.OrderBy(x => x.Username).Select(x => x.Username).Distinct();
            return (from s in list select new SelectListItem { Value = s, Text = s }
           );
        }
    }

    public IEnumerable<SelectListItem> DistinctMethods
    {
        get
        {
            var list = TraceLogs.OrderBy(x => x.Method).Select(x => x.Method).Distinct();
            return (from s in list select new SelectListItem { Value = s, Text = s }
           );
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# linq refactoring

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

如何在Rxjs中映射深层嵌套的对象

我开始使用angular2中的rxjs.在将http响应映射到observable时,我见过的许多例子都使用了简单的对象.

 this.http.get('/app/shared/data/raw-tasks.json')
        .map(response => response.json())
        .map(stream => stream.map(res => new TaskModel(res.name, res.deadline, res.timeRequired)))
Run Code Online (Sandbox Code Playgroud)

但是我如何映射更复杂的响应,如嵌套对象和嵌套数组?

rxjs angular

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