1
Vote

Use LinqTextQueryBuilder on ASP.net MVC

description

I'm new for ASP.net MVC . When I try to use LinqTextQueryBuilder on asp.net mvc, I find that it could not run ! with step by step, I find the way to solved the problem:
    Step 1:
                    Assembly entryAssembly = Assembly.GetEntryAssembly() ;
     (at AddEntryAssemblyReferences_() in LinqTextQueryRuntimeProfiler class)

             GetEntryAssembly() return Null when app in asp.net. 
    http://bytes.com/topic/net/answers/412182-assembly-getentryassembly

        you should replace GetEntryAssembly() into GetExecutingAssemby().

   Step 2:

            In my app,
         LinqTextQueryBuilder<MYDBDataContext> queryBuilder = new LinqTextQueryBuilder<MYDBDataContext>();

                        queryBuilder.Profiler.AddNamespace("MYDBDataContext");
                        queryBuilder.SetSource(m_DBoperate);

                        var query = queryBuilder.Query(strLinq);          
              but 
            if (_usedNamespaces != null)
                classText = classText.Replace("/Namespaces/", GetNamespacesDefination(_usedNamespaces));
            else
                classText = classText.Replace("/Namespaces/", string.Empty);
           /Namespaces/ just replace into MYDBDataContext, but in my app the using code need replace into " using MYapp.model.MYDBDataContext". so i simple replace like this:
// setting namespaces. if 'null' then replace with String.Empty
            //if (_usedNamespaces != null)
            //    classText = classText.Replace("/Namespaces/", GetNamespacesDefination(_usedNamespaces));
            //else
            //    classText = classText.Replace("/Namespaces/", string.Empty);
            classText = classText.Replace("/Namespaces/", string.Empty);
   Step 3:

            finally, I find  when construct the query command. I can't put the "\n" in it. 



Maybe Help for you

comments