Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在C中的新请求中使用Linq to SQL对象#_C#_Android_Ajax_Cordova_Model View Controller - Fatal编程技术网

C# 如何在C中的新请求中使用Linq to SQL对象#

C# 如何在C中的新请求中使用Linq to SQL对象#,c#,android,ajax,cordova,model-view-controller,C#,Android,Ajax,Cordova,Model View Controller,我在MVC和C#方面相对较新,在学习一些小东西时遇到了很多问题。我有一些错误,希望能得到任何帮助来解决我的问题。 我有以下两种型号: 通常: public Usuario LoginById(int Id) { var login = (from u in db.Usuario where u.IdUsuario == Id && u.Ativo == true s

我在MVC和C#方面相对较新,在学习一些小东西时遇到了很多问题。我有一些错误,希望能得到任何帮助来解决我的问题。 我有以下两种型号:

通常:

    public Usuario LoginById(int Id)
    {
        var login = (from u in db.Usuario
                     where u.IdUsuario == Id && u.Ativo == true
                     select u).FirstOrDefault();
        return login;
    }
通常情况下:

    public UsuarioDevice getByUUID(string uuid)
    {
        var usuariodevice = (from c in db.UsuarioDevice
                      where c.UuId == uuid
                      select c).FirstOrDefault();
        return usuariodevice;
    }
控制器:

public HttpResponseMessage GetConsultaLogUsu(string uuid){
        UsuarioDeviceDAL dev = new UsuarioDeviceDAL();
        UsuarioDAL obj = new UsuarioDAL();

        var device = dev.getByUUID(uuid);
        var usu obj.LoginById(device.IdUsuario); // this is the line that i would like to work.

        if (device != null){ 
        return new HttpResponseMessage(){
                Content = new StringContent("L")
            };
        }else{
            return new HttpResponseMessage(){
                Content = new StringContent("D")
            };
        }
    }
阿贾克斯:

}


如果有人知道如何解决这个问题,我会非常感激。谢谢大家的帮助。

我在您的
ajax
配置中做了几件事:

  • 删除了
    contentType:“application/json”
    ,因为您只发送查询字符串。默认情况下,
    contentType
    application/x-www-form-urlencoded;字符集=UTF-8
  • 而是手动配置查询字符串参数,我添加为
    data
    选项
  • 我在
    error
    处理程序中添加了参数,您将能够检查出现的错误
请查看您的案例中的外观:

   $.ajax({
        type: "GET",
        url: linkServidor + "api/GuardaUsuario/GetConsultaLogUsu",
        data: {
            'uuid': uuid
        },
        success: function(data) {
            navigator.notification.alert(data, fn_ErroApp(), "Sucesso teste.");
            if (data === 'L') {
                window.location.href = "verdelandia.html";
            }
        },
        error: function(xhr, ajaxOptions, thrownError) {
            navigator.notification.alert("Estamos verificando o problema.", fn_ErroApp(), "Ocorreu um problema.");
        }
    }); 
改为创建URL作为字符串,您可以尝试使用:

@Url.Action(“actionName”,“controllerName”,新{uuid=”“})

我有一些错误
您有哪些错误?谢谢您的提问。他曾经陷入ajax的错误信息中。
   $.ajax({
        type: "GET",
        url: linkServidor + "api/GuardaUsuario/GetConsultaLogUsu",
        data: {
            'uuid': uuid
        },
        success: function(data) {
            navigator.notification.alert(data, fn_ErroApp(), "Sucesso teste.");
            if (data === 'L') {
                window.location.href = "verdelandia.html";
            }
        },
        error: function(xhr, ajaxOptions, thrownError) {
            navigator.notification.alert("Estamos verificando o problema.", fn_ErroApp(), "Ocorreu um problema.");
        }
    }); 
@Url.Action("actionName", "controllerName", new { uuid= "<uuid>" })