小编Jit*_*oli的帖子

如何从postgresql数据库生成edmx

我在postgresql中有一个数据库,我想在我的项目中使用vs 2010(v4.0)中的向导生成edmx(实体框架).

我按照本博客http://fxjr.blogspot.in/2011/05/npgsql-design-time-support-preview.html中给出的所有步骤进行了操作, 但在生成edmx时我找不到postgresql的数据提供程序.

我也见过http://ud-csharp.blogspot.in/2010/02/entity-framework-con-postgresql.html,但没有取得任何成功.

.net entity-framework npgsql asp.net-mvc-3

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

动态地使用字符串绑定对象属性

我有一个下面的课

public class SearchModel
{
    public string Locations { get; set; }
    public string City { get; set; }
    public string Address { get; set; } 
    public string MaxRecord { get; set; }
    public string PageSize { get; set; }
    ....
    ....
    Approx 80 properties
}
Run Code Online (Sandbox Code Playgroud)

我有一个查询字符串 "my location_Locations/new york_City/city street_Address/200_MaxRecord/20_PageSize"

上面的字符串包含类的确切属性名称SearchModel.现在我想做以下事情: -

SearchModel model = new SearchModel();
string[] Parameters = "my location_Locations/new york_City/city street_Address/200_MaxRecord/20_PageSize".Split('/');
foreach (string item in Parameters)
{
    string[] value=item.Split('_');
    model.value[1] = value[0];
}
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net asp.net-mvc

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

如何根据某些条件创建对象

如何实现以下类型的东西?

dynamic prod = vid.HasValue ? 
              CatalogRepository.GetProductDetailByProductId(pid.Value, vid)
            : CatalogRepository.GetProductDetailByProductId(pid.Value);
Run Code Online (Sandbox Code Playgroud)

GetProductDetailByProductId(pid.Value)返回一个Object of Productwhile GetProductDetailByProductId(pid.Value, vid)返回一个Object ProductVariant.

我将对象分配给动态变量,因此应该在运行时识别它,但它在编译时给出了类型转换错误.

c# asp.net asp.net-mvc-4

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

队列不存在或您没有足够的权限来执行操作.通过MSMQ发送消息时出现异常

我创建了一个通过MSMQ发送消息但在执行时获得异常的函数.以下是我的功能.

public void SendMessageToQueue(ChessQueue chessQueue)
{
    MessageQueue queue = null;
    Message m = null;
    if (!MessageQueue.Exists(".\\Private$\\" + chessQueue.QueueName))
    {
        queue = new MessageQueue(".\\Private$\\chessqueue");
        chessQueue.Messages = new List<MessageObject>();
        chessQueue.Messages.Add(chessQueue.Message);
        queue.Formatter = new BinaryMessageFormatter();
        m = new Message();
        m.Body = chessQueue;
    }
    else
    {
        queue = new MessageQueue(".\\Private$\\" + chessQueue.QueueName);
        queue.Formatter = new BinaryMessageFormatter();
        m = queue.Receive();
        ChessQueue ExistingChessQueue = m.Body as ChessQueue;
        ExistingChessQueue.Messages.Add(chessQueue.Message);
        m.Body = ExistingChessQueue;
    }            
    queue.Send(m);
    // Getting Exception at this Line
}
Run Code Online (Sandbox Code Playgroud)

例外: - 队列不存在或您没有足够的权限来执行操作.

此外,我无法在"计算机管理"下打开"消息队列"的安全选项卡.请参见附件截图. 在此输入图像描述

我尝试在私人手动下创建消息队列,系统允许我这样做.见下文 在此输入图像描述

下面是mmc跨度. 在此输入图像描述

.net msmq message-queue send system.messaging

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

获取System.Net.WebException:远程服务器返回错误:(403)Forbidden.在Google URL Shortener API Call中

我使用下面的代码来缩短长网址

public static string UrlShorten(string url)
{
    string post = "{\"longUrl\": \"" + url + "\"}";
    string shortUrl = url;
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/urlshortener/v1/url?key=" + ReadConfig("GoogleUrlShortnerApiKey"));
    try
    {
        request.ServicePoint.Expect100Continue = false;
        request.Method = "POST";
        request.ContentLength = post.Length;
        request.ContentType = "application/json";
        request.Headers.Add("Cache-Control", "no-cache");

        using (Stream requestStream = request.GetRequestStream())
        {
            byte[] postBuffer = Encoding.ASCII.GetBytes(post);
            requestStream.Write(postBuffer, 0, postBuffer.Length);
        }

        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        {
            using (Stream responseStream = response.GetResponseStream())
            {
                using (StreamReader responseReader = new StreamReader(responseStream))
                {
                    string json = responseReader.ReadToEnd();
                    shortUrl …
Run Code Online (Sandbox Code Playgroud)

c# google-api google-url-shortener

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

如何为除MVC3中的一个特殊URL之外的所有URL运行自定义路由

我已经完成了一些URL路由,就像某些URL一样.

routes.MapRoute(
                "ProductDetails",
                "Product/{name}/{*other}",
                new { controller = "Product", action = "Details" }
            );
Run Code Online (Sandbox Code Playgroud)

上面的代码将路由所有/Product/{name}类型的URL /Product/Details/{parameter}.它工作正常,现在我想要,如果我输入网址/Product/List,这必须通过默认路由处理.

我不想再为List创建一条路线.

请指教.

model-view-controller asp.net-mvc asp.net-mvc-3

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

stopPropagation 和 preventDefault 不起作用,父点击仍在触发

在我的代码中,我添加onclick了父 div 并希望对内部 div 执行其他操作,但单击内部 div 也会触发父单击。如何阻止?

$(document).on('click', '.child', function(e) {
  e.preventDefault();
  e.stopPropagation();
  console.log('child');
});

function parentfun(sender) {
  console.log('parent');
}
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="parent" onclick="parentfun(this)">
  parent
  <div class="child">child</div>
</div>
Run Code Online (Sandbox Code Playgroud)
上面的 div 是在其他事件的运行时生成的。

点击孩子,也会触发父母的点击。preventDefault 和 stopPropagation 不起作用。

仅供参考:我的问题与单击子锚点时如何防止父级的 onclick 事件触发不同?

javascript jquery

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

如何从Yahoo Local获取评论和评分?

如何使用像这样的URL从雅虎本地获得评论和评级http://local.yahoo.com/info-11057512-gray-s-papaya-new-york;_ylt=AqfdTH3jqpVj68gKIK09u6WGNcIF;_ylv=3.

api yahoo review yahoo-api

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