当前位置: 首页>>代码示例>>C#>>正文


C# DBContext类代码示例

本文整理汇总了C#中DBContext的典型用法代码示例。如果您正苦于以下问题:C# DBContext类的具体用法?C# DBContext怎么用?C# DBContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DBContext类属于命名空间,在下文中一共展示了DBContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerificarUsuario

        public static Usuario VerificarUsuario(string password, int user)
        {
            try
            {
                var usuario = new Usuario();

                using (DBContext db = new DBContext())
                {
                    var check = Encrypt(password);
                    var pass = Decrypt(password);
                    var query = from u in db.Usuario
                                where u.idUsuario == user && u.senhaUsuario == pass
                                select u;
                    foreach (Usuario u in query)
                    {
                        usuario = u;
                    }
                }
                return usuario;
            }
            catch (Exception)
            {
                return null;
            }
        }
开发者ID:elSilveira,项目名称:iaziServerWeb,代码行数:25,代码来源:Simple.cs

示例2: Aggregate

        public override Exceptional<IObject> Aggregate(AAttributeIndex attributeIndex, GraphDBType graphDBType, DBContext dbContext)
        {
            //if (graphDBType.IsAbstract)
            //{
            //    #region For abstract types, count all attribute idx of the subtypes

            //    UInt64 count = 0;

            //    foreach (var aSubType in dbContext.DBTypeManager.GetAllSubtypes(graphDBType, false))
            //    {
            //        if (!aSubType.IsAbstract)
            //        {
            //            count += aSubType.GetUUIDIndex(dbContext.DBTypeManager).GetValueCount();
            //        }
            //    }

            //    return new Exceptional<IObject>(new DBUInt64(count));

            //    #endregion
            //}
            //else
            //{
                #region Return the count of idx values

                var indexRelatedType = dbContext.DBTypeManager.GetTypeByUUID(attributeIndex.IndexRelatedTypeUUID);

                return new Exceptional<IObject>(new DBUInt64(attributeIndex.GetValueCount()));

                #endregion
            //}
        }
开发者ID:TheByte,项目名称:sones,代码行数:31,代码来源:CountAggregate.cs

示例3: VerificarUsuarioBomo

        public static BomoUsuario VerificarUsuarioBomo(string password, string user)
        {
            try
            {
                var usuario = new BomoUsuario();

                DBContext db = new DBContext();

                //var check = Encrypt(password);
                var pass = Encrypt(password);
                var query = from u in db.BomoUsuario
                            where u.bomoCliente.email == user && u.senha == pass
                            select u;
                foreach (BomoUsuario u in query)
                {
                    usuario = u;
                }

                return usuario;
            }
            catch (Exception)
            {
                return null;
            }
        }
开发者ID:elSilveira,项目名称:iaziServerWeb,代码行数:25,代码来源:Simple.cs

示例4: AddBulletin

        public ActionResult AddBulletin(string packageid, FormCollection form)
        {
            SetMenuSelection("Apps");

            if (Session["UserID"] == null)
                return RedirectToAction("Login", "Home");

            DBContext db = new DBContext();
            ViewData["PackageID"] = packageid;

            if (form.Count > 0)
            {
                //create
                if (form["txtCreateTitle"] == string.Empty)
                {
                    ViewData["CreateStatus"] = "Title is required";
                    return View();
                }

                MetrixBulletinBoardAnnouncement mbba = new MetrixBulletinBoardAnnouncement();
                mbba.Message = form["editorCreate"];
                mbba.PackageID = packageid;
                mbba.Title = form["txtCreateTitle"];
                db.MetrixBulletinBoardAnnouncements.InsertOnSubmit(mbba);
                db.SubmitChanges();

                Response.Redirect("/Apps/Bulletin/" + packageid);
            }

            return View();
        }
开发者ID:Arcticus,项目名称:Metrix-webOS-Analytics,代码行数:31,代码来源:AppsController.cs

示例5: IndexSingleOperation

        public override IEnumerable<ObjectUUID> IndexSingleOperation(AAttributeIndex myIndex, ADBBaseObject myOperationValue, AttributeUUID myAttributeUUID, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            IndexKey lookup = new IndexKey(myAttributeUUID, myOperationValue, myIndex.IndexKeyDefinition);
            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            var result = myIndex.Contains(lookup, currentType, dbContext);
            if (result.Value)
            {
                var interestingUUIDs = myIndex.GetValues(lookup, currentType, dbContext);

                foreach (var aIndexValue in myIndex.GetAllValues(currentType, dbContext))
                {
                    foreach (var aUUID in aIndexValue)
                    {
                        if (!interestingUUIDs.Contains(aUUID))
                        {
                            yield return aUUID;
                        }
                    }
                }
            }
            else
            {
                foreach (var aIndexValue in myIndex.GetKeyValues(currentType, dbContext).Select(kv => kv.Value))
                {
                    foreach (var aUUID in aIndexValue)
                    {
                        yield return aUUID;
                    }
                }
            }

            yield break;
        }
开发者ID:Vadi,项目名称:sones,代码行数:34,代码来源:NotInOperator.cs

示例6: Aggregate

        public override Exceptional<IObject> Aggregate(AAttributeIndex attributeIndex, GraphDBType graphDBType, DBContext dbContext)
        {
            if (attributeIndex is UUIDIndex)
            {
                return new Exceptional<IObject>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true), "Aggregating attribute UUID is not implemented!"));
            }
            else
            {
                var indexRelatedType = dbContext.DBTypeManager.GetTypeByUUID(attributeIndex.IndexRelatedTypeUUID);

                // HACK: rewrite as soon as we have real attribute index keys
                if (attributeIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs.Count != 1)
                {
                    return new Exceptional<IObject>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
                }

                var typeAttr = graphDBType.GetTypeAttributeByUUID(attributeIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs.First());
                ADBBaseObject oneVal = typeAttr.GetADBBaseObjectType(dbContext.DBTypeManager);

                return new Exceptional<IObject>(attributeIndex.GetKeyValues(indexRelatedType, dbContext).AsParallel().Select(kv =>
                {
                    var mul = oneVal.Clone(kv.Key);
                    mul.Mul(oneVal.Clone(kv.Value.Count()));
                    return mul;

                }).Aggregate(oneVal.Clone(), (elem, result) => { result.Add(elem); return result; }));
            }
        }
开发者ID:TheByte,项目名称:sones,代码行数:28,代码来源:SumAggregate.cs

示例7: Aggregate

        public override Exceptional<FuncParameter> Aggregate(IEnumerable<DBObjectStream> myDBObjects, TypeAttribute myTypeAttribute, DBContext myDBContext, params Functions.ParameterValue[] myParameters)
        {
            var aggregateResult = new DBDouble(0d);
            var total = 0UL;

            foreach (var dbo in myDBObjects)
            {
                var attr = dbo.GetAttribute(myTypeAttribute, myTypeAttribute.GetDBType(myDBContext.DBTypeManager), myDBContext);
                if (attr.Failed())
                {
                    return new Exceptional<FuncParameter>(attr);
                }
                if (attr.Value != null && attr.Value is ADBBaseObject && aggregateResult.IsValidValue((attr.Value as ADBBaseObject).Value))
                {
                    aggregateResult.Add((attr.Value as ADBBaseObject));
                    total++;
                }
                else
                {
                    return new Exceptional<FuncParameter>(new Error_AggregateIsNotValidOnThisAttribute(myTypeAttribute.Name));
                }
            }
            aggregateResult.Div(new DBUInt64(total));

            return new Exceptional<FuncParameter>(new FuncParameter(aggregateResult));
        }
开发者ID:Vadi,项目名称:sones,代码行数:26,代码来源:AvgAggregate.cs

示例8: About

        public ActionResult About()
        {
            AboutListViewModel aboutListViewModel = new AboutListViewModel();

            //add AboutViewModel
            List<AboutViewModel> listAVM = new List<AboutViewModel>();
            List<About> listAbout = new DBContext().Abouts.Where(a => a.IsDelete != true).OrderBy(a => a.Id).ToList();
            AboutViewModel AboutViewModel;
            foreach (var item in listAbout)
            {
                AboutViewModel = new AboutViewModel();
                AboutViewModel.Title = item.Title;
                AboutViewModel.Content = item.content;
                AboutViewModel.Thumbnail = item.Thumbnails;
                listAVM.Add(AboutViewModel);
            }
            aboutListViewModel.listAboutViewModel = listAVM;

            //Add Welcome
            Welcome welcome = new DBContext().Welcomes.Where(w => w.IsDelete != null).FirstOrDefault();
            if (welcome != null)
            {
                aboutListViewModel.WelcomeTitle = welcome.Title;
                aboutListViewModel.WelcomeContext = welcome.Content;
                aboutListViewModel.WelcomeBackground = welcome.Background;
                aboutListViewModel.WelcomeLinkVideo = welcome.LinkVideo;
            }
            return View(aboutListViewModel);
        }
开发者ID:Gobackhome,项目名称:lengkeng,代码行数:29,代码来源:HomeController.cs

示例9: IndexOperation

        public override IEnumerable<ObjectUUID> IndexOperation(AAttributeIndex myIndex, TupleDefinition myTuple, TypesOfBinaryExpression typeOfBinExpr, DBContext dbContext)
        {
            if (myTuple.Count() != 2)
            {
                throw new GraphDBException(new Error_InvalidInRangeInterval(2, myTuple.Count()));
            }

            var currentType = dbContext.DBTypeManager.GetTypeByUUID(myIndex.IndexRelatedTypeUUID);

            #region As soon as the index supports ranges use them!!

            //limits
            var fromKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (myTuple.ElementAt(0).Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);
            var toKey = new IndexKey(myIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs[0], (myTuple.ElementAt(1).Value as ValueDefinition).Value, myIndex.IndexKeyDefinition);

            switch (myTuple.KindOfTuple)
            {
                case KindOfTuple.Inclusive:
                    return myIndex.InRange(fromKey, toKey, true, true, currentType, dbContext);
                case KindOfTuple.LeftExclusive:
                    return myIndex.InRange(fromKey, toKey, false, true, currentType, dbContext);
                case KindOfTuple.RightExclusive:
                    return myIndex.InRange(fromKey, toKey, true, false, currentType, dbContext);
                case KindOfTuple.Exclusive:
                    return myIndex.InRange(fromKey, toKey, false, false, currentType, dbContext);
                default:
                    throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace(true)));
            }

            #endregion
        }
开发者ID:TheByte,项目名称:sones,代码行数:31,代码来源:InRangeOperator.cs

示例10: Get

        public async Task<IEnumerable<CvViewModel>> Get()
        {
            List<CvViewModel> cvs = new List<CvViewModel>();

            DirectoryInfo photoFolder = new DirectoryInfo(this.workingFolder);
            var db = new DBContext();
            var cvList = new List<CvViewModel>();

            await Task.Factory.StartNew(() =>
            {
                cvs = photoFolder.EnumerateFiles()
                                            .Where(fi => new[] { ".doc", ".pdf", ".docx", ".txt", ".rtf", ".odt" }.Contains(fi.Extension.ToLower()))
                                            .Select(fi => new CvViewModel
                                            {
                                                Name = fi.Name,                                                
                                                Created = fi.CreationTime,
                                                Modified = fi.LastWriteTime,
                                                Size = fi.Length / 1024
                                            })
                                            .ToList();
               
                foreach (var item in cvs)
	            {
                    // TODO check if Resume is deleted
                    var resume = db.CVs.FirstOrDefault(f => f.Name.Equals(item.Name, StringComparison.InvariantCultureIgnoreCase));
                    if (resume!= null)
                    {
                        item.Id = resume.Guid;
                        cvList.Add(item);
                    }
	            }
            });

            return cvList;
        }
开发者ID:flyeven,项目名称:AngJobs,代码行数:35,代码来源:LocalCvManager.cs

示例11: Import

        public override QueryResult Import(IEnumerable<String> myLines, IGraphDBSession myIGraphDBSession, DBContext myDBContext, UInt32 parallelTasks = 1, IEnumerable<String> comments = null, ulong? offset = null, ulong? limit = null, VerbosityTypes verbosityTypes = VerbosityTypes.Errors)
        {
            var gqlQuery = new GraphQLQuery(myDBContext.DBPluginManager);

            #region Evaluate Limit and Offset

            if (offset != null)
            {
                myLines = myLines.SkipULong(offset.Value);
            }
            if (limit != null)
            {
                myLines = myLines.TakeULong(limit.Value);
            }

            #endregion

            var queryResult = new QueryResult();

            #region Import queries

            if (parallelTasks > 1)
            {
                queryResult = ExecuteAsParallel(myLines, myIGraphDBSession, gqlQuery, verbosityTypes, parallelTasks, comments);
            }
            else
            {
                queryResult = ExecuteAsSingleThread(myLines, myIGraphDBSession, gqlQuery, verbosityTypes, comments);
            }

            #endregion

            return queryResult;
        }
开发者ID:TheByte,项目名称:sones,代码行数:34,代码来源:GraphDBImport_GQL.cs

示例12: GridView1_GetData

 public IQueryable<CompStore.Model.Employee> GridView1_GetData()
 {
     var db = new DBContext();
     IQueryable<CompStore.Model.Employee> result = from b in db.People.OfType<Employee>()
                                                   select b;
     return result;
 }
开发者ID:ugeHidalgo,项目名称:ComputerStoreWF,代码行数:7,代码来源:Employees.aspx.cs

示例13: GetValueForAttribute

        /// <summary>
        /// <seealso cref=" AAttributeAssignOrUpdate"/>
        /// </summary>
        public override Exceptional<IObject> GetValueForAttribute(DBObjectStream myDBObject, DBContext myDBContext, GraphDBType myGraphDBType)
        {
            if (AttributeIDChain.IsUndefinedAttribute)
            {
                return new Exceptional<IObject>(GraphDBTypeMapper.GetBaseObjectFromCSharpType(Value));
            }

            #region Simple value

            var dbType = AttributeIDChain.LastAttribute.GetDBType(myDBContext.DBTypeManager);
            if (AttributeIDChain.LastAttribute is SpecialTypeAttribute_UUID)
            {
                dbType = myDBContext.DBTypeManager.GetTypeByName(GraphDBTypeMapper.GetBaseObjectFromCSharpType(Value).ObjectName);//DBString.Name);
            }
            if (GraphDBTypeMapper.IsAValidAttributeType(dbType, AttributeAssignType, myDBContext, Value))
            {
                return new Exceptional<IObject>(GraphDBTypeMapper.GetGraphObjectFromType(AttributeAssignType, Value)); ;
            }
            else
            {
                return new Exceptional<IObject>(new Error_InvalidAttributeValue(AttributeIDChain.LastAttribute.Name, Value));
            }

            #endregion
        }
开发者ID:Vadi,项目名称:sones,代码行数:28,代码来源:AttributeAssignOrUpdateValue.cs

示例14: Aggregate

        public override Exceptional<IObject> Aggregate(IEnumerable<DBObjectStream> myDBObjects, TypeAttribute myTypeAttribute, DBContext myDBContext, params Functions.ParameterValue[] myParameters)
        {
            var foundFirstMax = false;
            var aggregateResult = myTypeAttribute.GetADBBaseObjectType(myDBContext.DBTypeManager);
            foreach (var dbo in myDBObjects)
            {
                var attrResult = dbo.GetAttribute(myTypeAttribute, myTypeAttribute.GetDBType(myDBContext.DBTypeManager), myDBContext);
                if (attrResult.Failed())
                {
                    return attrResult;
                }
                var attr = attrResult.Value;

                if (attr != null && attr is ADBBaseObject && aggregateResult.IsValidValue((attr as ADBBaseObject).Value))
                {
                    if (foundFirstMax == false)
                    {
                        aggregateResult.Value = (attr as ADBBaseObject).Value;
                        foundFirstMax = true;
                    }
                    else
                    {
                        if (aggregateResult.CompareTo((attr as ADBBaseObject).Value) < 0)
                        {
                            aggregateResult.Value = (attr as ADBBaseObject).Value;
                        }
                    }
                }
                else
                {
                    return new Exceptional<IObject>(new Error_AggregateIsNotValidOnThisAttribute(myTypeAttribute.Name));
                }
            }
            return new Exceptional<IObject>(aggregateResult);
        }
开发者ID:TheByte,项目名称:sones,代码行数:35,代码来源:MaxAggregate.cs

示例15: RemoveBackwardEdges

        protected Exceptional RemoveBackwardEdges(TypeUUID myTypeUUID, Dictionary<AttributeUUID, object> myUserdefinedAttributes, ObjectUUID myObjectUUIDReference, DBContext myDBContext)
        {
            #region get type that carries the attributes

            var aType = myDBContext.DBTypeManager.GetTypeByUUID(myTypeUUID);

            #endregion

            #region process attributes

            foreach (var aUserDefinedAttribute in myUserdefinedAttributes)
            {

                #region Data

                GraphDBType typeOFAttribute = null;
                TypeAttribute attributesOfType = null;

                #endregion

                #region get GraphType of Attribute

                attributesOfType = aType.Attributes[aUserDefinedAttribute.Key];

                typeOFAttribute = myDBContext.DBTypeManager.GetTypeByUUID(attributesOfType.DBTypeUUID);

                #endregion

                IEnumerable<Exceptional<DBObjectStream>> listOfObjects;

                if (aUserDefinedAttribute.Value is IReferenceEdge)
                {
                    listOfObjects = ((IReferenceEdge)aUserDefinedAttribute.Value).GetAllEdgeDestinations(myDBContext.DBObjectCache);
                }
                else
                {
                    listOfObjects = myDBContext.DBObjectCache.LoadListOfDBObjectStreams(typeOFAttribute, (HashSet<ObjectUUID>)aUserDefinedAttribute.Value);
                }

                foreach (var aDBObject in listOfObjects)
                {
                    if (aDBObject.Failed())
                    {
                        return new Exceptional(aDBObject);
                    }

                    var removeExcept = myDBContext.DBObjectManager.RemoveBackwardEdge(aDBObject.Value, myTypeUUID, aUserDefinedAttribute.Key, myObjectUUIDReference);

                    if (removeExcept.Failed())
                    {
                        return new Exceptional(removeExcept);
                    }
                }

            }

            #endregion

            return Exceptional.OK;
        }
开发者ID:TheByte,项目名称:sones,代码行数:60,代码来源:AAttributeAssignOrUpdateOrRemove.cs


注:本文中的DBContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。