0

I have a problem with this SQL sentence:

SELECT     DOCUMENTOS.*
FROM         DOCUMENTOS 
INNER JOIN
                      DOCUMENTOS_NOTARIOS ON DOCUMENTOS.uniCODOBJ = DOCUMENTOS_NOTARIOS.UNICODDOC 
INNER JOIN
                      NOTARIOS ON DOCUMENTOS_NOTARIOS.UNICODNOT = NOTARIOS.uniCODOBJ
Where notarios.unicodobj = '84B11CDE-1C4B-4D0F-8C68-A54074B8D652' 

I would to pass to LINQ for entity framework and I need the results into IQueryable list

I Tried this but I don't know how to pass to IQueryable list,

List<DOCUMENTOS> DocumentosByNotarioList = new List<DOCUMENTOS>();
                var query = from d in db.DOCUMENTOS
                            join dn in db.DOCUMENTOS_NOTARIOS on d.uniCODOBJ equals dn.UNICODDOC
                            join n in db.NOTARIOS on dn.UNICODNOT equals n.uniCODOBJ
                            where n.uniCODOBJ == test
                            select new
                            {
                                d.uniCODOBJ,
                                d.strTITOL,
                                d.strNOMPRO,
                                d.strFECINI,
                                d.strFECFIN
                            };

I don't undertand very well this languange I prefer this type...

DocumentsList = db.DOCUMENTOS
                    .Where(d => nombre == null || d.strTITOL.Contains(nombre))
                    .Where(d => fechaIni == string.Empty || d.strFECINI.Equals(fechaIni))
                    .Where(d => fechaFin == string.Empty || d.strFECFIN.Equals(fechaFin))
                    .Where(d => tipoLibro == Guid.Empty || d.uniCODSER == tipoLibro)
                    .Where(d => firmaTopo == null || d.strFIRTOP == firmaTopo)
                    .OrderByDescending(d => d.datFECCER).ToList();

Thanks for advance!

4

2 回答 2

0

假设您不能将匿名类型转换为 DOCUMENTOS 类型。根本不做投影:

var query = from d in db.DOCUMENTOS
            join dn in db.DOCUMENTOS_NOTARIOS on d.uniCODOBJ equals dn.UNICODDOC
            join n in db.NOTARIOS on dn.UNICODNOT equals n.uniCODOBJ
            where n.uniCODOBJ == test
            select d;

var DocumentosByNotarioList = query.ToList();
于 2013-07-30T15:12:40.120 回答
0

我不是很明白。我有这个功能,因为我正在使用 MVC,我需要这个 iqueryable 来传递给视图,这个视图包含一个基础网格..

public static IQueryable<DOCUMENTOS> GetDocumentosByNotario()
            {
                Guid test = new Guid("84B11CDE-1C4B-4D0F-8C68-A54074B8D652");
                netCNCEntities db = new netCNCEntities();
                List<DOCUMENTOS> DocumentosByNotarioList = new List<DOCUMENTOS>();

                var query = from d in db.DOCUMENTOS
                            join dn in db.DOCUMENTOS_NOTARIOS on d.uniCODOBJ equals dn.UNICODDOC
                            join n in db.NOTARIOS on dn.UNICODNOT equals n.uniCODOBJ
                            where n.uniCODOBJ == test
                            select d;

                var DocumentosByNotarioList = query.ToList();
}

非常感谢您的帮助!!!

于 2013-07-31T08:07:40.123 回答