如何使用SQL查询绑定angularjs菜单和子菜单? [英] How to bind angularjs menu and sub menu using SQL queries?

查看:109
本文介绍了如何使用SQL查询绑定angularjs菜单和子菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



你能告诉我如何在不使用实体框架的情况下使用SQL查询或stroed程序在mvc中绑定angularjs菜单和子菜单吗?



先谢谢,



Mohamed Kalith K



我尝试过:



使用SQL查询或stroed过程在mvc中绑定angularjs菜单和子菜单,而不使用实体框架

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

推荐答案

您可以使用SqlDataAdapter,SqlCommand和SqlConnection之类的东西来对SQL服务器(或者就此而言的MySql)数据库执行任务。如果您不使用EF,那么您可以自行管理相关实体之间的关系(导航属性)。 EF会为您使用其中的一些东西。这是我很久以前写的一个程序的摘录(它是一个Web服务,但它只是数据访问层部分,所以它可以用于WinForms)它从问题池中选择一个问题进行测验。 br $>


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.

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;
}


这篇关于如何使用SQL查询绑定angularjs菜单和子菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆