Click here to Skip to main content
14,930,371 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

Can you plesae show me how to bind angularjs menu and submenu in mvc using SQL queries or stroed procedure without using entity framework?

Thanks in Advance,

Mohamed Kalith K

What I have tried:

bind angularjs menu and submenu in mvc using SQL queries or stroed procedure without using entity framework
Posted
Updated 3-Aug-18 7:47am
Comments
F-ES Sitecore 3-Aug-18 6:08am
   
What do you want to use instead of Entity Framework? Your question is like asking "How long do I cook meat that isn't chicken?" What you don't want to use is irrelevant, we need to know what you do want to use.
kalithmk 3-Aug-18 10:17am
   
I want to use sql queries or stored procedure(ADO.Net) in c#

1 solution

You can use things like SqlDataAdapter, SqlCommand, and SqlConnection to perform tasks against a SQL server (or MySql for that matter) database. If you don't use EF then you take it upon yourself to manage the relationships between entities that are related (navigation properties). EF uses some of these things for you. Here's an excerpt from a program I wrote a very long time ago (it was for a web service but it's just the data access layer portion so it could be used for WinForms) It selects a single question for a quiz from a question pool.

C#
public Question SelectDatabaseRecord(int nId)
{
	Question entity;
	SqlParamList lstParams;
	DataTable dt;
	DataSet ds;
	DataRow dr;

	lstParams = new SqlParamList();
	lstParams.AddSqlParam("@Id", DbType.Int32, ParameterDirection.Input, nId);
	ds = DataProvider.GetDataSet("spQuestionSelectById", lstParams);
	dt = ds.Tables[0];
	if (dt.Rows.Count > 0)
	{
		entity = new Question();
		dr = dt.Rows[0];
		Populate(ref entity, dr); // populate filled the properties of the entity from the DataRow

		return entity;
	}
	return null;
}

// IN DataProvider
public static DataSet GetDataSet(string strProcName, List<SqlParameter> lstParams)
{
	DataSet dsResult = new DataSet();
	SqlConnection conn = GetConnection();
	SqlDataAdapter da;

	if (conn != null)
	{
		conn.Open();
		da = new SqlDataAdapter(strProcName, conn);
		da.SelectCommand = conn.CreateCommand();
		da.SelectCommand.CommandType = CommandType.StoredProcedure;
		da.SelectCommand.CommandText = strProcName;
		if (lstParams != null)
			foreach (SqlParameter sqlParam in lstParams)
				da.SelectCommand.Parameters.Add(sqlParam);

		da.Fill(dsResult);
		da.SelectCommand.Dispose();
		conn.Close();
		conn.Dispose();
	}

	return dsResult;
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900