When I generate the DAL via SubCommander/sonic.exe I get an empty StoredProcedures.cs
All that's in it is:using System;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;
using SubSonic;
using SubSonic.Utilities;
Does anyone have a clue why this happens?
I'm using SubSonic 2.1, all other classes are generated properly.
Edit:
I tried: GRANT ALL ON PROCEDURE testDb.testStoredProc TO 'testUser'#'%';
But it doesn't appear even if the user has all privilegies to the stored proc.
Edit 2:
I am using MySQL 5 database
Do you have includeProcedureList or excludeProcedureList defined in your config options. I would guess you've got something like excludeProcedureList="*" or includeProcedureList=""
This is a known error with the Oracle Provider. What database are you using?
Related
I'm new in asp.net mvc and first time create new web application and in my project solution right click and add new project to solution and add class library to my project,and name it Datalayer,so in Datalayercreate new class and name it PageGroup,in PageGroup want to add System.ComponentModel.DataAnnotations to name space but get this error:
A namespace cannot directly contain members such as fields or methods...
I add entity frame work to datalayer but so not work!,how can i solve that problem?
this is my class code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel;
namespace Datalayer
{
public class PageGroup
{
[Key]
public int GroupID { get; set; }
}
}
in [Key] get error.
I think you forgot to add assembly reference in your application.
Go to Reference->Add Reference-> Select System.ComponentModel.DataAnnotations assembly to your application.
Then use the namespace in your application
using System.ComponentModel.DataAnnotations;
Please find screenshot for reference
Add assembly system.ComponentModel.DataAnnotation in your current project.
Go to Add reference> Assemblies > Framework and choose system.ComponentModel.DataAnnotation
If this is not present in your current assembly then download it form nuget package manager.
Write click on your project.> manage nuget packages and search for System.componentmodel and select appropriate package and install.
I have a bit of a problem. I have created all my models in a different Class Library. Now, I have to create a controller in a MVC Web Application using the models present in the Class Library. I am not able to see the Models that I created in the Class Library while creating a controller in MVC. How do I proceed on getting all the models in Class Library to the MVC project. I have even added a reference of the Class Library to the MVC project.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DomainClasses;
namespace TestingModel.Controllers
{
public class ProductsGroupController : Controller
{ //
// GET: /ProductsGroup/
public ActionResult Index()
{
return View();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web;
namespace DomainClasses.Models
{
public class ProductGroupMaster
{
public int ProductGroupID { get; set; }
}
}
Why is this? I have a feeling that it has something to do with my controller.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NidecMotorXref.MvcUI.BaseControllers;
using System.Web.Mvc;
using LINQtoCSV;
using System.IO;
[HttpPost]
public virtual ActionResult Matches(ImportModel model, string save, HttpPostedFileBase fileUpload)
{ ... }
These are all my references but File.Delete("myfileName") does not resolve while my higher up acted like it should. Even though my solution works with System.IO.File I was curious why it doesn't resolve my reference?
Controller defines a method called File, therefore the compiler will choose this method when resolving the symbol File.
When used within a class that does not include a File symbol then the compiler will fall back on resolving via the using statements, hence File.Delete working in other classes.
Im using EF model in my project. Im using viewmodel in my controllers show data. However, I can't access db.entry in my repository. How come I can't access it?
This my repository
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MCT.ViewModels;
using System.Data.Entity;
using System.Data;
namespace MCT.Models
{
public class AdministrationRep
{
Model1Container _db = new Model1Container();
public void changequstion(Question _question)
{
}
In my repository I'd like to use
db.entry(model).State = EntityState.Modified;
Or is there another way to use edit for my controller?
In the ObjectContext API you can change the state as follows
db.ObjectStateManager.ChangeObjectState(model, EntityState.Modified);
In ASP.NET MVC is there a way to enumerate the controllers through code and get their name?
example:
AccountController
HomeController
PersonController
would give me a list such as:
Account, Home, Person
Using Jon's suggestion of reflecting through the assembly, here is a snippet you may find useful:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web.Mvc;
public class MvcHelper
{
private static List<Type> GetSubClasses<T>()
{
return Assembly.GetCallingAssembly().GetTypes().Where(
type => type.IsSubclassOf(typeof(T))).ToList();
}
public List<string> GetControllerNames()
{
List<string> controllerNames = new List<string>();
GetSubClasses<Controller>().ForEach(
type => controllerNames.Add(type.Name));
return controllerNames;
}
}
You can reflect through your assembly and find all classes which inherit from type System.Web.MVC.Controller. Here's some sample code that shows how you could do that:
http://mvcsitemap.codeplex.com/WorkItem/View.aspx?WorkItemId=1567
All who using this post better read this post before: using Assembly.GetCallingAssembly() not returns the calling assembly
The issue is that razor views are acting as independent dynamic assemblies and you don't get the desired assembly.
Yair
Create the property in every controller and then you get the name like this.