本文整理汇总了C#中DataClassesDataContext类的典型用法代码示例。如果您正苦于以下问题:C# DataClassesDataContext类的具体用法?C# DataClassesDataContext怎么用?C# DataClassesDataContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataClassesDataContext类属于命名空间,在下文中一共展示了DataClassesDataContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
DataClassesDataContext da = new DataClassesDataContext();
var result1 = from n in da.user
where n.user_name == TextBox3.Text
select n.major;
var result2 = from m in da.project
where m.project_num == DropDownList1.Text
select m.major;
foreach (var n in result1)
{
foreach (var m in result2)
{
if (n != m)
{
ClientScriptManager client = this.ClientScript;
client.RegisterStartupScript(this.GetType(), "55", "<script>alert('专业不符!');history.back()</script>");
return;
}
}
}
proposal p = new proposal();
p.proposal1 = TextBox1.Text;
p.project_num = DropDownList1.Text;
p.teacher_name = DropDownList2.Text;
p.user_name = TextBox3.Text;
p.proposal_num = TextBox2.Text;
da.proposal.InsertOnSubmit(p);
da.SubmitChanges();
GridView1.DataBind();
}
示例2: Index
public ActionResult Index(string username, string password)
{
DataClassesDataContext db = new DataClassesDataContext();
if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
{
return View();
}
if (db.Users.Where(u => u.nick == username).Count() < 1)
{
db.Users.InsertOnSubmit(new User { nick = username, password = password });
db.SubmitChanges();
}
if (db.Users.Where(u => u.nick == username && u.password == password).Count() > 0)
{
Session["login"] = true;
Session["nick"] = username;
Session["userid"] = db.Users.Where(u => u.nick == username).First().id;
Session["type"] = db.Users.Where(u => u.nick == username).First().type;
return RedirectToAction("Index", "Chat");
}
else
{
ViewBag.ErrorMessage = "Nicket er ikke tilgjengelig!";
return View();
}
}
示例3: BuildEditorNavigation
public string BuildEditorNavigation()
{
DataClassesDataContext db = new DataClassesDataContext();
string category_id = "0";
if (Request.QueryString["category_id"] != null)
{
category_id = Request.QueryString["category_id"].ToString();
}
string MenuItems = "";
List<dbCategory> kategori_title = new List<dbCategory>();
if (Convert.ToInt32(Session["role_access"]) >= 100)
{
kategori_title = db.dbCategories.OrderBy(i => i.Id).ToList();
}
else
{
kategori_title = db.dbCategoryEditors.Where(i => i.UserId == Convert.ToInt32(Session["user_id"])).Select(ce => ce.dbCategory).OrderBy(i => i.Id).ToList();
}
foreach (var item in kategori_title)
{
string active = (Request.RawUrl.Contains("News.aspx") && category_id == item.Id.ToString() ? " class='active'" : "");
MenuItems += String.Format("<li{2}><a href='{0}'>{1}</a></li>", "News.aspx?category_id=" + item.Id, item.Title, active);
}
return MenuItems;
}
示例4: Getauthor
public musicdata[] Getauthor(string author)
{
//if (!Hasmusic(author))
//{
// var error = new CustomFaultMsg { Message = "Không có bài nào author là : " + author };
// throw new FaultException<CustomFaultMsg>(error, error.Message);
//}
using (var musicct = new DataClassesDataContext())
{
var song = from music in musicct.SONGs
where music.MUSICIAN.IndexOf(author) != -1
select new musicdata
{
Id = music.SONGID.ToString(),
aTitle = music.SONGNAME,
bAuthor = music.MUSICIAN,
Lang = music.LANGUAGE,
cSinger = music.SINGER.SINGERNAME,
eGenre = music.CATEGORY,
dPublish = music.PUBLISH.ToString(),
Karaoke = music.KARAOKE.ToString(),
Emotion = music.EMOTION.EMOTIONTYPE,
Instrument = music.INSTRUMENT,
Lyric = music.LYRICS
};
return song.ToList().ToArray();
}
}
示例5: LinkButtonCredit_Click
protected void LinkButtonCredit_Click(object sender, EventArgs e)
{
PanelCredit.Visible = true;
PanelAdd.Visible = false;
PanelLog.Visible = false;
LinkButtonCredit.Enabled = false;
LinkButtonAdd.Enabled = true;
LinkButtonLog.Enabled = true;
DataClassesDataContext context = new DataClassesDataContext();
int Userid = Convert.ToInt32(Session["UserId"]);
var query2 = context.Credits.Where(c => c.UserId == Userid).FirstOrDefault();
if (query2 != null)
{
LabelGiftCredit.Text = query2.GiftCredit.ToString();
LabelSpendGift.Text = query2.SpentGift.ToString();
LabelSpentCreadit.Text = query2.SpentCredit.ToString();
LabelCredit.Text = query2.Credit1.ToString();
}
else if (query2 == null)
{
LabelGiftCredit.Text = " 0 ";
LabelSpendGift.Text = " 0 ";
LabelSpentCreadit.Text = " 0 ";
LabelCredit.Text = " 0 ";
}
}
示例6: GetSlides
public AjaxControlToolkit.Slide[] GetSlides(String contextKey)
{
List<AjaxControlToolkit.Slide> slides = new List<AjaxControlToolkit.Slide>();
if (String.IsNullOrEmpty(contextKey))
contextKey = "2";
int artIndex = -1;
if (int.TryParse(contextKey, out artIndex))
{
DataClassesDataContext dtx = new DataClassesDataContext();
var pics = from p in dtx.Pictures
where p.ArticleId == artIndex
select new
{
Id = p.Id,
Title = p.Title
};
foreach (var p in pics)
{
slides.Add(new AjaxControlToolkit.Slide("sqlimage.axd?name=pic&picId=" + p.Id, p.Title, ""));
}
}
return slides.ToArray();
}
示例7: initDutyTable
private void initDutyTable()
{
DataClassesDataContext db = new DataClassesDataContext();
FillTable ft = new FillTable(10, 7);
ft.creatDataArray(db.Duty.ToList());
ft.fillDataArrayToTable(DutyTable,NoValueDisplay.NoValueString);
}
示例8: getPostingByID
public IQueryable<ndhCareer> getPostingByID(int _id)
{
DataClassesDataContext objDataClassesDC = new DataClassesDataContext();
var postingID = objDataClassesDC.ndhCareers.Where(x => x.id == _id).Select(x => x);
return postingID;
}
示例9: getPosting
public IQueryable<ndhCareer> getPosting()
{
DataClassesDataContext objDataClassesDC = new DataClassesDataContext();
//var allPostings = from x in objDataClassesDC.ndhCareers select x;
var allPostings = objDataClassesDC.ndhCareers.Select(x => x); //method syntax
return allPostings;
}
示例10: SubmitButton_Click
protected void SubmitButton_Click(object sender, EventArgs e)
{
TextBox commentCtrl = (TextBox)CommentsLoginView.FindControl("CommentTextBox");
if (commentCtrl != null && commentCtrl.Text.Length > 0)
{
using (DataClassesDataContext dtx = new DataClassesDataContext())
{
int aid = 0;
MembershipUser mu = Membership.GetUser(HttpContext.Current.User.Identity.Name);
if (int.TryParse(Context.Request["aid"], out aid))
{
var comment = new Comment()
{
ArticleId = aid,
UserId = (Guid)mu.ProviderUserKey,
Body = commentCtrl.Text,
Created = System.DateTime.Now
};
dtx.Comments.InsertOnSubmit(comment);
dtx.SubmitChanges();
CommentService c = new CommentService();
CommentsDataList.DataSource = c.GetComments(aid);
CommentsDataList.DataBind();
}
commentCtrl.Text = "";
}
}
}
示例11: button1_Click
protected void button1_Click(object sender, EventArgs e)
{
if (textbox1.Text.Equals(String.Empty) || textbox2.Text.Equals(String.Empty))
{
Label1.Text = "评论内容与验证码不能为空";
return;
}
try
{
if (!Request.Cookies["ValiCode"].Value.ToString().Equals(textbox2.Text))
{
Label1.Text = "验证码错误";
return;
}
Table_DocumentComment comment = new Table_DocumentComment();
comment.AccountName = Session["name"].ToString();
comment.AccountType = Session["type"].ToString();
comment.Comment = textbox1.Text;
comment.Date = DateTime.Now;
comment.DocumentId = (Int32)Session["document"];
DataClassesDataContext data = new DataClassesDataContext();
data.Table_DocumentComment.InsertOnSubmit(comment);
data.SubmitChanges();
comments.Add(comment);
textbox1.Text = String.Empty;
textbox2.Text = String.Empty;
Label1.Text = String.Empty;
}
catch (Exception) { }
}
示例12: initDutyTable
private void initDutyTable(string id)
{
DataClassesDataContext db = new DataClassesDataContext();
FillTable ft = new FillTable(10, 7);
ft.creatDataArray(db.Duty.Where(dutys=>dutys.assistantID==id).ToList());
ft.fillDataArrayToTable(DutyTable,NoValueDisplay.Nothing);
}
示例13: PrzydzielZadanieButton_Click
protected void PrzydzielZadanieButton_Click(object sender, EventArgs e)
{
List<int> idGrupList = new List<int>();
for (int i = 0; i < EnableGroupsListView.Items.Count; i++)
{
CheckBox chk = EnableGroupsListView.Items[i].FindControl("NazwaCheckBox") as CheckBox;
if (chk != null && chk.Checked)
{
idGrupList.Add((int)EnableGroupsListView.DataKeys[i].Value);
}
}
DataClassesDataContext db = new DataClassesDataContext();
Zadania zadanie = db.Zadanias.FirstOrDefault(g => g.IdZadania == (int)((DataKey)Session["IdZadania"]).Value);
foreach (int id in idGrupList)
{
ZadaniawGrupach zadaniawGrupach = new ZadaniawGrupach
{
Zadania = zadanie,
IdGrupy = id,
DataDodania = DateTime.Now
};
db.ZadaniawGrupaches.InsertOnSubmit(zadaniawGrupach);
}
db.SubmitChanges();
WczytajListeGrup(db);
SuccesLabel.Text = "Dodano zadanie do grup/y";
SuccesLabel.ForeColor = System.Drawing.Color.Green;
}
示例14: GetAll
public List<PersonData> GetAll()
{
var ctx = WebOperationContext.Current;
try
{
using (var personCtx = new DataClassesDataContext())
{
// Set up the query
var persons = from p in personCtx.Persons
orderby p.FirstName
select new PersonData
{
PersonId = p.PersonId,
FirstName = p.FirstName,
LastName = p.LastName,
EmailAddress = p.EmailAddress,
Department = p.Department
};
ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
return persons.ToList();
}
}
catch
{
ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest;
return null;
}
}
示例15: GetPerson
public PersonData GetPerson(string personId)
{
var ctx = WebOperationContext.Current;
try
{
using (var personCtx = new DataClassesDataContext())
{
// Set up the query
var person = personCtx.Persons.SingleOrDefault(p => p.PersonId == Convert.ToInt32(personId));
if (person == null)
{
ctx.OutgoingResponse.SetStatusAsNotFound();
return null;
}
var personData = new PersonData
{
PersonId = person.PersonId,
FirstName = person.FirstName,
LastName = person.LastName,
EmailAddress = person.EmailAddress,
Department = person.Department
};
ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
return personData;
}
}
catch
{
ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest;
return null;
}
}